Mysql – “Access denied for user ‘root’@’servername’ (using password: NO)” – except I AM using a password

MySQLrhel5

This is weird. Our web server is running RHEL 5.5, and has the MySQL client version 5.5.10 installed (just updated from a 5.0 build, which was having the same problem). When I connect to the database server (which is NOT localhost) via "mysql –host=dbserver -uroot -p" and provide the password, it fails with "Access denied for user 'root'@'servername' (using password: NO)". Of course, I am supplying a password. If I try to log in with a different account, and just punch in any old junk password, it fails with "Access denied for user 'otheruser'@'dbserver' (using password: YES)". So what on earth is making it refuse to supply the password when I attempt to log in as root?

For comparison, we have another internal server running Windows 2003, and it has MySQL 5.0.45 installed. I can log in with the root account from there just fine. Is there some obscure SELinux setting on our web server that's preventing the password from being sent?

(And no, I'm not trying to set up the web site to connect to the database as root. There's a dedicated user for that. This is just something that might need to be done from time to time for testing/setup.)

Best Answer

You need to explicitly grant the user permission to connect from that host- like this; (remove < > and replace with correct string)

GRANT ALL PRIVILEGES ON <dbname>.* TO '<db-username>'@'<hostname>' IDENTIFIED BY '<user-password>' WITH GRANT OPTION;