Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

4 Answers 4

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 http://24x7servermanagement.com/blog/?p=44)

#service mysqld stop or
#killall mysqld
#/usr/bin/mysqld_safe –skip-grant-tables&
#/usr/bin/mysql
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;
mysql>quit
/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 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=545741

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

 
discard

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.