Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'

I installed mysql by snap.

mysql.startup

initialize mysql and set root user and a temporary password to it.
when i want to connect to mysql server it show me error:

mysql.client -uroot -p

Using config file: /home/hamid/snap/mysql/common/conf/my.cnf
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I solved the issue.
Stop the MySQL server , then restart it with the - -skip-grant-tables

mysql.server --skip-grant-tables

Connect to the MySQL server using the [mysql]client; no password is necessary because the server was started with [--skip-grant-tables]

mysql.client

after connecting to Mysql Server

mysql> FLUSH PRIVILEGES;

then reset root password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.