yuri90
yuri90

Reputation: 83

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

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'

Upvotes: 0

Views: 50881

Answers (4)

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';

Upvotes: 0

Krishna
Krishna

Reputation: 1

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

Upvotes: -1

yuri90
yuri90

Reputation: 83

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

Upvotes: 6

Anonymous Duck
Anonymous Duck

Reputation: 2998

Grant all privileges to the user first ,

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

Upvotes: 2

Related Questions