k1ngarthur
k1ngarthur

Reputation: 124

MYSQL Access denied for root (pw-reset not working)

I have an interseting problem. I try to access my mysql server as root (also not wirking with debain-sys-maint) unsing

sudo mysql -u root -p

I reinstalled complete server (purged all).

sudo mysql_secure_installation

worked once after reinstall. and then

sudo mysql

worked. But after reset auth to native password I still get this error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

regardless what i am doing, there is no login to mysql possible. Any ideas to solve that?

Upvotes: 1

Views: 154

Answers (1)

user1986815
user1986815

Reputation:

first stop the service

service mysql stop


then start mysql in single user mode :

mysqld_safe –skip-grant-tables &

Then log in without any password

mysql

then change root'S password "new_pass"

UPDATE mysql.user SET password=password(‘new_pass’) WHERE User=’root’;

at the end :

FLUSH PRIVILEGES;
exit;

now you are on console again using mysqladmin log in using your new password and shutdown the singleusermode

mysqladmin -u root -p shutdown

Here shutdown is not the password it is the command, you will be prompted for the password.

then you start the mysql service normally

service mysql start

Upvotes: 1

Related Questions