Skip to content

Instantly share code, notes, and snippets.

@alexwebgr
Last active March 16, 2024 11:23
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • 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