服务器之家:专注于服务器技术及软件下载分享
分类导航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|数据库技术|

服务器之家 - 数据库 - Mysql - 解决mysql: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)

2021-08-24 17:23Winton-H Mysql

今天给大家分享一篇教程帮助大家解决mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)的问题,非常不错,特此分享到脚本之家平台供大家学习

一、问题

  有时候我们登录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:

    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) 的资料请关注服务器之家其它相关文章!

原文链接:https://www.cnblogs.com/winton-nfs/p/12956811.html

延伸 · 阅读

精彩推荐