LINUX, FOSS AND LIBRARY TECHNOLOGY ENTHUSIAST

Wednesday, April 15, 2020

Fix MySQL/MariaDB Error: : 'Access denied for user 'root'@'localhost'

0 comments
To fix MySQL/Mariadb Error: : 'Access denied for user 'root'@'localhost', you should follow these steps:

Step 1: Open and Edit /etc/my.cnf or /etc/mysql/my.cnf, according to your distro.

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf  (MariaDB 10.3 on Debian 10)

Step 2: Add skip-grant-tables under [mysqld]

Step 3: Restart Mysql

sudo systemctl restart mysql

You must be able to login to mysql now by using the below command mysql -u root -p

Run mysql> flush privileges;

Now, set a new password by

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword'; 

and go back to /etc/my.cnf and remove/comment skip-grant-tables

Again, Restart Mysql, now you can log in with the new password 

No comments:

Post a Comment