0

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;.
3
  • user ''@'localhost' implies you connected anonymously, which likely means unprivileged. If you want to modify the mysql database you must connect with a privileged user (and directly writing to mysql.user is probably not a good idea - better to use SET PASSWORD instead dev.mysql.com/doc/refman/5.0/en/set-password.html) Commented May 15, 2015 at 3:01
  • please disable any firewalls first, antivirus program or windows may be blocking it Commented May 15, 2015 at 4:24
  • yes I had to disable antivirus and firewall, but still can not enter the command mysql> use mysql; Commented May 15, 2015 at 5:41

4 Answers 4

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

ERROR 1054 (42S22): Unknown column 'Password' in 'field list'
2

Grant all privileges to the user first ,

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

13 Comments

thank you for your replay Maku. but what should I do for this? I mean what commands should I use? sorry I'm a beginner
mysql> GRANT ALL PRIVILEGES ON . TO 'user'@'localhost' WITH GRANT OPTION; ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO)
what is the password of your mysql?
I do not sure how many times I changed the password and what I managed to replace / reset the password. whether password can be reset directly ? But when I'm looking for a way to reset it that I found the following commands: use mysql; UPDATE user SET Password=PASSWORD("password") WHERE User='root'; flush privileges; quit
Just set your password to none, SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');, less hassle for development and execute grant command again
|
0

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

Comments

-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.