且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

访问被拒绝用户'root'@'localhost'(使用密码:是)密码重置后LINUX

更新时间:2023-09-28 22:13:58

实际上,我仔细看了mysql数据库中的用户表,在我之前编辑了ssl_type字段为用户root到SSL。



我编辑该字段并重新启动mysql,它的工作方式类似一个魅力。



谢谢。


I have a MySQL installed on my linux server, I forgot it's password so I went and changed it using the methods I found on the web. What I did was as follows:

/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql --user root mysql
SELECT * FROM user; // I checked if I could access the user table or not
update user SET password = PASSWORD('new_pass') WHERE user = 'root';
flush privileges;
exit

The update query did change the password as it showed me the number of rows affected and Query OK etc.

Then I restarted mysql

/etc/init.d/mysql stop
/etc/init.d/mysql start

Now when I logged in with the new password

mysql -u root -p new_pass

it still gives me errors "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Yes)"

Is there something that I am missing?

Actually I took a closer look at the user table in mysql database, turns out someone prior to me edited the ssl_type field for user root to SSL.

I edited that field and restarted mysql and it worked like a charm.

Thanks.