一、问题

有时候我们登录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/myf配置文件

进入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:

1、net stop mysql 2、net start mysql

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

Enter Password>‘新密码’

就不会出错,可以登录啦!!!

(另外一种情况就是,,你密码输入错误了,如果是初始化后第一次登录,出现这种情况的话,很大概率就是密码错误,初始化后的密码要认真查看,可能会因为空格、小数点等符号输错)

以上就是解决mysql:ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO/YES)的详细内容,更多关于ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO/YES) 的资料请关注脚本之家其它相关文章!

更多推荐

解决mysql:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using pas