Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

This is the first time I've had to reach out for a question -- I'm truly stumped.

I have mysql up and running on a linux server (Ubuntu) and this morning tried to login to phpMyAdmin. I received an error that said I can't login. So I went to the command line, typed in mysql -u root -p and when prompted for the password, entered it correctly. I then received the following error:

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

Here's the weird thing:

I can't connect via mysql on the command line nor through phpMyAdmin, but all my WordPress sites are working fine. However, if I try to login with one of the WP sites' credentials, I get the same kind of error as above.

I checked etc/mysql/my.cnf and saw: bind-address = I tried to comment this out and restart mysql, no luck. I tried to change bind-address to localhost, and still no luck. Right now it's back to bind-address = This is the same setting I have for a second Linode with the exact same private ip/networking settings as this one (I set both of their static IPs up at the same time), yet the other server is working fine (can connect to MySQL) and this one just seems to hate me.

So the big question is: What is causing mysql to no longer allow me to connect, why can my WordPress sites still use their credentials (but I can't via phpmyadmin nor the command line), and how can I prevent this from eluding me in the future?

Possibly pertinent details:

  • Two days ago I setup a private IP on this linode.

  • cat /etc/hosts does contain localhost localhost.localdomain localhost

  • ping localhost does return results:

    ping localhost
    PING localhost.localdomain ( 56(84) bytes of data.
    64 bytes from localhost.localdomain ( icmp_req=1 ttl=64 time=0.066 ms
    64 bytes from localhost.localdomain ( icmp_req=2 ttl=64 time=0.062 ms
  • Rebooted recently for the first time in two months -- Could that have something to do with it?

  • It seems like the root password automagically just changed on me...

Thank you so much for helping me out.

share|improve this question
up vote 0 down vote accepted

I ran across something similar to this, while setting up mysql. MySQL doesn't consider localhost and to be the same accessible address (despite documents often using them interchangeably). The trick is, in your case getting connected to make changes to who can connect and how. I'd try conncting to the loopback IP explicitly:

mysql -h -u root -p

If that doesn't work you'll have to dig through your wordpress settings to find the host, port, username and password settings. The good news is if wordpress is working there is a way to get in.

Once you're connected your problem is in the mysql database (use mysql) in the users table. It's either that access control only allows one of IP, or anonymous users that are messing up your connections.

To see if you have any anonymous users:

SELECT User,host from mysql.user;

If you see anything with blank @ localhost etc, that's them. To remove:

DELETE From mysql.user where User='' and host='localhost';
share|improve this answer
This is a very applicable answer to a variety of problems but in my case it was not. The ping results ruled out the 127.0.0.l problem that is very common (and I think you were addressing here). I ended up having to shut down mysql and then start it back up with skip-grant-tables, then basically did what you said from paragraph 2 on. As it turns out, the only thing I can think of that killed the mysql root password was a system reboot. oh well. I'm marking this answer as the correct one because it is the one that fits the widest variety of circumstances. Thank you for taking time to answer! – user236192 Jan 21 '14 at 21:08
So you think that some how the root password was corrupted during an update? That's worrying if it's a risk. – Rudu Jan 22 '14 at 0:13
I checked and rechecked all of my logs (I journal everything I do just for this reason), and a restart after apt-get upgrade was the last big thing that I did. After that it was just some cat and grep calls. – user236192 Jan 23 '14 at 16:30

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.