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

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 127.0.0.1 3306
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    A
    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 127.0.0.1, 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 stackoverflow.com Mar 11 '11 at 2:02

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

2 Answers 2

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@127.0.0.1

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]@'127.0.0.1' IDENTIFIED BY '[PASSWORD]';
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.