zoukankan      html  css  js  c++  java
  • 解决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>'新密码'

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

  • 相关阅读:
    OC中Foundation框架之NSDictionary、NSMutableDictionary
    【03_136】Single Number
    【算法】QuickSort
    【02_258】Add Digits
    【01_292】Nim Game
    做题过程中得到的注意点
    No.02——第一次使用Android Studio,并创建出Hello World
    No.01——配置编程环境
    一个好用的代码分享网站
    【数据结构】某些难理解点
  • 原文地址:https://www.cnblogs.com/winton-nfs/p/12956811.html
Copyright © 2011-2022 走看看