Skip to content

Instantly share code, notes, and snippets.

@alexwebgr
Last active September 23, 2024 09:40
Show Gist options
  • Save alexwebgr/e438dcbb1eba91af8131736cfbfe9b80 to your computer and use it in GitHub Desktop.
Save alexwebgr/e438dcbb1eba91af8131736cfbfe9b80 to your computer and use it in GitHub Desktop.
Install MySQL on ubuntu 20.04 and set the root password
# Completely remove any previous config
sudo apt remove --purge mysql*
sudo apt autoremove
sudo find / -iname mysql
# install the server
sudo apt update
sudo apt install mysql-server
# run the wizard
sudo mysql_secure_installation
sudo mysql
mysql> use mysql;
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
# enable password login
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> exit;
# should be able to login with password now
mysql -u root -p
Enter password:
mysql>
@jboussouf
Copy link

I still get this error:
Error: Access denied for user 'root'@'localhost' (using password: NO)

@alexwebgr
Copy link
Author

alexwebgr commented Aug 26, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment