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'm trying to install a PHP-based tool which connects to a MySQL database, hosted on Ubuntu. I can log into the MySQL database from the command line, but running the app results in this error:

Access denied for user '[user]'@'localhost' (using password: YES)

What I've done: Using guidance from this discussion, here are some troubleshooting steps I've taken.

  • Trying to connect to MySQL via Telnet results in this garbled nonsense:

    $ telnet 3306
    Connected to
    Escape character is '^]'.
    5.1.41-3ubuntu12.10XIs(ja&7FyO`r>zpDAY{Connection closed by foreign host.
  • My /etc/hosts.deny file is empty. I've added the following lines to my /etc/hosts.allow file:

    mysqld: ALL : ALLOW mysqld-max: ALL : ALLOW

  • Although the bind-address in my /etc/mysql/my.cnf file was set to, I commented it out to no avail.

  • Disable the firewall

  • Flush privileges

It should be noted that I restarted MySQL after each of these steps using the following command:

mysqladmin -u [user] -p shutdown
mysqld_safe &

What am I missing?

share|improve this question

migrated from Mar 11 '11 at 2:02

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

If mysql admin works does the client program work?

If the client program works one possibility is the mysql client library is out of date and needs to be updated. (I'm more familiar with RedHat but it's probably something like sudo apt-get update php-mysql .. not 100% sure on that package name)

Also make sure that you are using the exact name you set the user up with. If you setup the user as user@localhost it might not work to use user@

hope that helps

share|improve this answer
The password was incorrect in the stored config file. An embarrassing mistake but worth posting in case it helps someone else with the same issue. – Dan Mar 18 '11 at 17:00

Try this

mysql >GRANT ALL ON [database name].* TO [user]@'' IDENTIFIED BY '[PASSWORD]';
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.