mysql> use mysql; but ... ERROR 1044 (42000): Access denied for user '' @ 'localhost' to database 'mysql'

49.1k Views Asked by At

Using mysql.exe, I enter the command mysql> use mysql; but there is an error:

ERROR 1044 (42000): Access denied for user '' @ 'localhost' to database 'mysql'

  • What does this mean?
  • How so I can access a mysql database?
  • The most important thing is that I want to reset password mysql database, but an error occurs when I enter the command: mysql> use mysql;.
4

There are 4 best solutions below

1
yuri90 On BEST ANSWER

thanks all, finally I found this reset root password with wrong mysql config… and it works well for me :)

-Go to your xampp\mysql\bin\ folder
-Edit my.ini and insert skip-grant-tables below [mysqld]
-Restart MySQL
-Set new password for your root user by running UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root' in phpMyAdmin in the mysql database (or just leave it like this if MySQL cannot be accessed from remote hosts)

AndreKR

13
Anonymous Duck On

Grant all privileges to the user first ,

GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
0
Krishna On

Open MySQL interface (phpMyadmin) through browser then

  1. click Users
  2. check users with grant options if it is no then follow below steps
  3. click->edit privileges (if user with 'no' grant option)
  4. then select (global privileges) mark check all
  5. continue these steps to all users
0
Super Kai - Kazuya Ito On

I got the same error below:

ERROR 1044 (42000): Access denied for user 'john'@'localhost' to database 'mysql'

When I tried to select mysql database(schema) by login with the user john as shown below:

use mysql

So, I gave all privileges on all the tables in mysql database(schema) (mysql.*) to the user john with GRANT by login with the user root as shown below, then I could solve the error:

GRANT ALL ON mysql.* TO 'john'@'localhost';

Or:

GRANT ALL PRIVILEGES ON mysql.* TO 'john'@'localhost';