问题描述
我在我的 linux 服务器上安装了一个 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.
然后我重启了mysql
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
它仍然给我错误错误 1045 (28000):用户 'root'@'localhost' 访问被拒绝(使用密码:是)"
有什么我遗漏的吗?
推荐答案
其实我仔细看了一下mysql数据库中的user表,发现之前有人把root用户的ssl_type字段修改为SSL.
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.
我编辑了该字段并重新启动了 mysql,它就像一个魅力.
I edited that field and restarted mysql and it worked like a charm.
谢谢.
这篇关于密码重置 LINUX 后,用户 'root'@'localhost' 的访问被拒绝(使用密码:是)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!