zoukankan      html  css  js  c++  java
  • mysql ERROR 1045 (28000): Access denied for user解决方法

     

    问题重现(以下讨论范围仅限Windows环境):

    C:AppServMySQL> mysql -u root -p
    Enter password:
    ERROR 1045 (28000): Access denied for user
     'root'@'localhost' (using password: YES)

    编辑mysql配置文件my.ini(不知道在哪请搜索),在[mysqld]这个条目下加入
      skip-grant-tables
    保存退出后重启mysql

    1.点击“开始”->“运行”(快捷键Win+R)。

      2.启动:输入 net stop mysql

      3.停止:输入 net start mysql

    这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为我们不能grant(没有权限)。按下面的流程走(红色部分为输入部分,粉红色的是执行后显示的代码不用输入):

    1.进入mysql数据库:

    mysql> use mysql;
    Database changed

    2.给root用户设置新密码,蓝色部分自己输入:
    mysql> update user set password=password("新密码") where user="root";
    Query OK, 1 rows affected (0.01 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    3.刷新数据库
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    4.退出mysql:
    mysql> quit
    Bye

    改好之后,再修改一下my.ini这个文件,把我们刚才加入的"skip-grant-tables"这行删除,保存退出再重启mysql就可以了。

  • 相关阅读:
    hdu 1325 判断有向图是否为树
    poj 1182
    Ubuntu 系统 文件操作命令
    vim 快捷键大全
    Git 上传本地命令
    git错误:fatal: Not a git repository (or any of the parent directories): .git
    Git 如何回到过去,然后 再 回到将来
    Git 提供篇
    Linux 的cp命令
    Linux :: vi E212: Can't open file for writing
  • 原文地址:https://www.cnblogs.com/u0mo5/p/4181289.html
Copyright © 2011-2022 走看看