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

    在实际登录redmine的过程中,我们遇到了如下的error

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

    Solution 1---空用户error.

    Solution 2---Windows 重置mysql root账户密码.

    Solution 2---Linux 重置mysql root账户密码.

    ==============================================

    以下结合网上的解决方案进行了初步分析:

    Solution 1---空用户error

    1、停用mysql服务:

     

    # service mysql stop

    2、输入命令: 

    # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

    3、登入数据库:

    # mysql -u root mysql

    4、mysql> use mysql;

    5、mysql> select user,host,password from user;

    结果如下:

    +------+-----------------------+----------+
    | user | host                            | password |
    +------+-----------------------+----------+
    | root | %                                 | mima |
    | root | localhost.localdomain  | mima |
    | root | 127.0.0.1                     | mima |
    |        | localhost                      |           |
    |         | localhost.localdomain |           |
    +------+-----------------------+----------+

    6、将上面查询出来的空用户删除:

    mysql> delete from user where user=' ';

    7、退出数据库:

    mysql> quit

    8、启动mysql服务:

    # service mysql start

    9、重新用命令:

    mysql -u root -p

    登录,OK!

     

    Solution 2---Windows 重置mysql root账户密码.

    搜索Windows上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就可以了。

     

    Solution 2---Linux 重置mysql root账户密码.

    1、停用mysql服务:

     

    # service mysql stop

    2、输入命令: 

    # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 

    3、登入数据库:

    # mysql -u root mysql

    4、mysql> use mysql;

    5、mysql> update user set password=password("新密码") where user="root";

    Query OK, 0 rows affected (0.13 sec)
    Rows matched: 4 Changed: 0 Warnings: 0

    6、刷新数据库

    mysql> flush privileges;
    Query OK, 0 rows affected (0.05 sec)

    mysql> quit
    Bye

    6、重启 $ sudo service mysql start

    mysql start/running, process 12719

    7、登录:

    $ mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 49
    Server version: 5.5.54-0ubuntu0.14.04.1 (Ubuntu)

    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

    mysql>

    成功登录。

     

    欢迎交流!

     

    参考:

    http://www.jb51.net/article/82421.htm

    http://blog.sina.com.cn/s/blog_759a5a7c01017dj0.html

  • 相关阅读:
    《神经网络和深度学习》系列文章三:sigmoid神经元
    《神经网络和深度学习》系列文章二:感知机
    《神经网络和深度学习》系列文章一:使用神经网络识别手写数字
    初遇python进程
    python-网络编程
    python常用模块详解2
    python根据正则表达式的简单爬虫
    python常用模块详解
    python-模块详解
    python-面向对象-内置方法补充
  • 原文地址:https://www.cnblogs.com/wangbaobao/p/7048905.html
Copyright © 2011-2022 走看看