ERROR 1044 (42000): Access denied for 'root' With All Privileges

后端 未结 4 1907
一生所求
一生所求 2020-12-01 08:06

I have strange error. I am logged in local Mysql as root via command line. After creating database:

create database some_db;

Then giving pr

4条回答
  •  长情又很酷
    2020-12-01 08:40

    First, Identify the user you are logged in as:

     select user();
     select current_user();
    

    The result for the first command is what you attempted to login as, the second is what you actually connected as. Confirm that you are logged in as root@localhost in mysql.

    Grant_priv to root@localhost. Here is how you can check.

    mysql> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;
    +-----------+------------------+-------------------------------------------+------------+------------+
    | host      | user             | password                                  | Grant_priv | Super_priv |
    +-----------+------------------+-------------------------------------------+------------+------------+
    | localhost | root             | ***************************************** | N          | Y          |
    | localhost | debian-sys-maint | ***************************************** | Y          | Y          |
    | localhost | staging          | ***************************************** | N          | N          |
    +-----------+------------------+-------------------------------------------+------------+------------+
    

    You can see that the Grant_priv is set to N for root@localhost. This needs to be Y. Below is how to fixed this:

    UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
    FLUSH PRIVILEGES;
    GRANT ALL ON *.* TO 'root'@'localhost';
    

    I logged back in, it was fine.

提交回复
热议问题