今天在windows下用navicat连接虚拟机的mysql时,出现1045错误,如图:

在虚拟机的mysql目录下,用mysqld_safe --user=mysql命令启动数据库,再用mysql -uroot -p命令登录数据库,然后执行以下命令:
set password = ‘123456’;
grant all privileges on . to ‘root’@’%’ identified by ‘123456’;
grant all privileges on . to ‘root’@’%’ identified by ‘123456’ with grant option;
flush privileges;
SELECT * from mysql.user\G;

找到root用户的authentication_string这项,并把它的值记下来,然后继续执行以下命令:
update mysql.user set authentication_string = ‘*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9’ where user = ‘root’;here user = ‘root’;
flush privileges;
此时再次连接,连接成功。

本文详细介绍了在Windows环境下使用Navicat连接虚拟机中MySQL时遇到的1045错误解决方案。通过调整MySQL权限及更新用户认证字符串,最终成功解决了连接问题。
1346

被折叠的 条评论
为什么被折叠?



