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 server in my room on my LAN. I just rebooted my server and now when I try to connect to mysql I get the following error message

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

I haven't changed any settings to my knowledge and was able to log in and out until I rebooted my computer. Any advice? I know this same error message has been reported on stackoverflow and serverfault, but in the Q/A's I read they aren't connecting to localhost.

share|improve this question
up vote 3 down vote accepted

The procedure is about the same; restart MySQL in safe mode log in with root and no password and perform a password reset. From there do a data integrity check.

share|improve this answer

Here is the list of steps I followed to solve this problem (from

#service mysqld stop or
#killall mysqld
#/usr/bin/mysqld_safe –skip-grant-tables&
mysql>use mysql;

Change the MySQL admin(root) Password using following command

mysql>update user set password=password(‘wsarxaffa’) where user=’root’ and host=’localhost’;

Flush the privileges so everything will take (It removes any privileges set by the server)

mysql>flush privileges;
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
mysql -u root -p
share|improve this answer

I faced this problem as well on ubuntu. In my case, the reason was that the /tmp folder was not accessible and install process was silently failing in root user creation. I'd uninstall mysql, give /tmp the right permissions and then reinstall mysql.

Please refer

share|improve this answer

I've seen this happen when mysql has been upgraded, and the grant tables were updated.

I would run /usr/bin/mysql_upgrade (or wherever the path is on your system) to fix that.

mysqld needs to be running.

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.