Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a fresh install of MySQL 5.5.19 on a CentOS 5 server. It is not letting me access anything or log in with phpMyAdmin. Below is the errors from trying different things.

$ mysql 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

$ mysql -u root -p
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I am able to restart mysqld but my problem is this error is hindering what I can do with MySQL. Thank you for any input.

share|improve this question
Are supplying the correct root password? – Khaled Dec 21 '11 at 15:58
I don't remember setting up a root mysql password. I just installed 5.5.19 and these errors are showing up so I figured I wouldn't even be able to enter a root password. Any advice on that? Thanks. – user1062058 Dec 21 '11 at 16:02
up vote 2 down vote accepted

You're correct in specifying the user with -u root -p, assuming the root user has a password on it.

The failure would imply that the wrong password is being entered. If you cannot get the login to work, you are stuck resetting the root password.

Add skip-grant-tables to your MySQL configuration and restart the service; this will allow root login with no password. Once that's done, set the password (update mysql.user set password=PASSWORD('newpass') where User='root';), verify that there's no craziness happening with the host specifications for root in the user table (and check for anonymous user specifications with a blank username, too; they can be problematic), remove the skip-grant-tables option, and restart the service. You should now be able to log in with your new password.

share|improve this answer
Thanks for the response, but how do I add the skip-grant-tables step? – user1062058 Dec 21 '11 at 16:10
Add it as a line in your /etc/my.cnf file. – Shane Madden Dec 21 '11 at 16:11
Thank you, it worked great. Have a nice day. – user1062058 Dec 21 '11 at 16:21

If you can access your mysql databases using the root account or you forgot your password, you can use the following instructions to reset it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.