mysql 登录密码错误解决方法1:ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO/YES)

mysql 登录密码错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)

本人机器配置: 系统:win10,mysql版本:5.7.36

一、问题

有时候我们登录Mysql输入密码的时候,会出现这种情况

mysql -u root -p

Enter Password > '密码'

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

或者:错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

二、解决办法

修改my.in/my.cnf配置文件

进入mysql安装目录,编辑my.ini

在[mysqld]下添加skip-grant-tables,保存即可。

①重启mysql,使用管理员身份打开命令行:

1、net stop mysql   2、net start mysql

②进入mysql,登录
mysql -u root -p
不用输入密码,直接回车(出现Enter Password 也一样直接回车,即可登陆成功)

③输入use mysql,修改root的密码:
update user set authentication_string=password('新密码') where user='root';
flush privileges;

④退出:quit;

重新进入mysql安装目录

编辑my.ini

在[mysqld]下删除skip-grant-tables,保存即可

⑤再次重启mysql:

1、net stop mysql     2、net start mysql

⑥测试是否成功就是是否登陆成功咯。
mysql -u root -p

Enter Password>'新密码'

出现 mysql>    表示成功登录mysql

 

另外一种解决密码错误的方式如下:

mysql 登录密码错误解决方法2:ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO/YES)

作者: 轻烟随风
当前文章地址: https://www.zyxpp.com/mysqlpassword1/
来源: 轻烟随风的博客
文章版权归作者所有,欢迎转载
THE END
分享
二维码
< <上一篇
下一篇>>