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;
yuri90
  • 83
  • 1
  • 1
  • 10
  • `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 https://dev.mysql.com/doc/refman/5.0/en/set-password.html) – Michael Berkowski May 15 '15 at 03:01
  • please disable any firewalls first, antivirus program or windows may be blocking it – Prasad Kharkar May 15 '15 at 04:24
  • yes I had to disable antivirus and firewall, but still can not enter the command mysql> use mysql; – yuri90 May 15 '15 at 05:41

3 Answers3

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

Community
  • 1
  • 1
yuri90
  • 83
  • 1
  • 1
  • 10
2

Grant all privileges to the user first ,

GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
Anonymous Duck
  • 2,942
  • 1
  • 12
  • 35
  • 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 – yuri90 May 15 '15 at 03:39
  • 2
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION; ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO) – yuri90 May 15 '15 at 03:51
  • what is the password of your mysql? – Anonymous Duck May 15 '15 at 05:50
  • 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 – yuri90 May 15 '15 at 06:27
  • Just set your password to none, SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');, less hassle for development and execute grant command again – Anonymous Duck May 15 '15 at 06:30
  • but to enter the command "use mysql;" absolutely can not. (I mean i just want toreset / replace the root mysql password. – yuri90 May 15 '15 at 06:31
  • i tried... mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD(''); ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql' – yuri90 May 15 '15 at 06:34
  • is "mysql" a database? – Anonymous Duck May 15 '15 at 06:35
  • simple advise, you can install wamp and sqlyog , this will lessen the burden, no need to use command line. – Anonymous Duck May 15 '15 at 06:36
  • I use xampp. that's what I do not understand, but not mysql database that I use. to reinstall xampp, I worry about losing the database, because the fault is I do not backup the database before. while I can not log into phpmyadmin also to backup the database :( – yuri90 May 15 '15 at 06:48
  • owww you forgot the password maybe :O – Anonymous Duck May 15 '15 at 06:49
  • thanks a lot maku, finally I found this http://stackoverflow.com/questions/4124447/reset-root-password-with-wrong-mysql-config and it works well for me :) – yuri90 May 15 '15 at 08:35
  • @yuri90 glad you got it now, happy coding!! – Anonymous Duck May 15 '15 at 09:01
-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
piet.t
  • 11,718
  • 21
  • 43
  • 52
Krishna
  • 1
  • 1