Access denied for user ‘root’@’localhost’

Ever got the following error message after installing MySQL on a Windows Server:

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

Sounds like this is quite a common problem if you look check in google.

This issue could have several roots:

  • The MySQL Service is not running
  • Service is not configured to accept network connections
  • Wrong password/username
  • Firewall setup
  • Wrong port (standard is 3306)

The mysql help actually has some good hints for these issues:

http://dev.mysql.com/doc/refman/5.0/en/access-denied.html

(From my own experience, port 3306 actually does not need to be open in order to use the MySql command line tool or the MySQL Workbench.)

My service was running and configured for tcp/ip, the firewall was disabled and the port was correct. So it had to be something with the password.

You can reset the root password like this:

  1. Stop the MySQL service:
    sc stop mysql
  2. Start MySQL with the –skip-grant-tables option, this disables the password checks. You might wanna start it in a different command prompt window.
    mysqld.exe –skip-grant-tables
  3. Run the following commands:
    mysql -u root mysql
    mysql> UPDATE user SET Password=PASSWORD(‘your_new_password’) where USER=’root’;
    mysql> FLUSH PRIVILEGES;
  4. Stop the Server:
    mysqladmin -uroot -pyour_new_password shutdown
  5. You should be able to login now
    mysql -uroot -pyour_new_password

If this does not help, there is a long discussion in the MySQL forum about this issue:

http://forums.mysql.com/read.php?11,34014,34014#msg-34014

Good luck!




Ähnliche Beiträge


Leave a Reply

Your email address will not be published. Required fields are marked *



*