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 have access to shared university research server that I want to host a php/mysql site on. I've compiled and run the mysql server and can connect to it fine using the 'mysql -u -h localhost -p', however when I use the exact same credentials and parameters through a PHP script, I always get 'access denied for user@localhost'. I did some more digging and found that even when my instance of the server isn't running, I get the same error message, which suggests there is an issue with the fact that this server is shared and running possibly multiple instances of mysqld. I've tried altering the port and socket and connecting to them explicitly through the script, but still have no had any luck. My PHP code works fine locally, so there's nothing syntactically wrong as far as I can tell.

Has anyone experienced a similar problem or can perhaps point me in the direction of some resources? Thanks in advance for your time!

share|improve this question
    
I think that this is a duplicate of this question serverfault.com/questions/56120/… –  Dana the Sane Aug 21 '09 at 1:09
    
Similar question but possibly a different cause. –  John Gardeniers Aug 21 '09 at 3:12

1 Answer 1

I've had this before. It turned out to be a problem with localhost not resolving properly or reliably. See what happens if you replace that with 127.0.0.1

share|improve this answer
    
I think this is the right direction. Check the hosts file and see what's first on the line for 127.0.0.1 and use that. (It could be 'localhost.localhost') –  Luke Aug 21 '09 at 3:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.