MySQL 的解决问题记录
1045 Access denied for user ‘root’@‘localhost’ (using password: YES)-个人解决后记录下
MySQL 连接错误,使用Navicat连接MySQL出现错误:1045 Access denied for user ‘root’@‘localhost’ (using password: YES)
解决方法:
- 编辑mysql配置文件my.ini(在mysql的安装目录下,不同电脑可能不一样,参考目录①D:\Program Files\MySQL\MySQL Server 5.0\my.ini;②C:\ProgramData\MySQL\MySQL Server 8.0\my.ini;),在[mysqld]这个条目下加入 skip-grant-tables 保存退出后重启mysql
- .打开cmd,点击“开始”->“运行”(快捷键Win+R)。
- 停止:输入 net stop mysql
- 启动:输入 net start mysql
也可以在计算机-管理-服务里面找到MySQL的服务,如图
这时候进入 Navicat 就不需要密码登录了,如果出现 password:的时候直接回车就可以进入,但很多操作都会受限制,因为没有grant权限。
老旧版本和新版本是有区别的:
进入后打开mysql数据库新建查询:给root用户设置新密码
老旧版本是用 password 做为密码字段:update user set password=password(“新密码”) where user=“root”;
新版本改为了 authentication_string 字段做为密码:update user set authentication_string=password(“新密码”) where user=“root”;
成功后刷新数据库可进入user表查看对应 root 用户名行 查看 “authentication_string” 密码字段是否更改完毕哦, 如 “password_expired” 密码过期字段 为 Y 的话 也需要该为 N 哦,不然也会出现一样的密码正确 确还是无法连接成功哦!
改好后 我们把之前修改的my.ini这个文件 “skip-grant-tables” 这行删除,保存退出再重启mysql服务,再重新用Navicat连接就可以了。酒酱 ojbk啦