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

后端 未结 4 1784
一生所求
一生所求 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.

    0 讨论(0)
  • 2020-12-01 08:40

    Try to comment string "sql-mode=..." in file my.cnf and than restart mysql.

    0 讨论(0)
  • 2020-12-01 08:42

    If you get an error 1044 (42000) when you try to run SQL commands in MySQL (which installed along XAMPP server) cmd prompt, then here's the solution:

    1. Close your MySQL command prompt.

    2. Open your cmd prompt (from Start menu -> run -> cmd) which will show: C:\Users\User>_

    3. Go to MySQL.exe by Typing the following commands:

    C:\Users\User>cd\ C:\>cd xampp C:\xampp>cd mysql C:\xxampp\mysql>cd bin C:\xampp\mysql\bin>mysql -u root

    1. Now try creating a new database by typing:

      mysql> create database employee;
      

      if it shows:

      Query OK, 1 row affected (0.00 sec)
      mysql>
      

      Then congrats ! You are good to go...

    0 讨论(0)
  • 2020-12-01 08:44

    The reason i could not delete some of the users via 'drop' statement was that there is a bug in Mysql http://bugs.mysql.com/bug.php?id=62255 with hostname containing upper case letters. The solution was running following query:

    DELETE FROM mysql.user where host='Some_Host_With_UpperCase_Letters';
    

    I am still trying to figure the other issue where the root user with all permissions are unable to grant privileges to new user for particular database

    0 讨论(0)
提交回复
热议问题