air air - 2 years ago 93
MySQL Question

MySQL working with but not working with localhost?

I have a strange problem in php MySQL:

php connects with
but not with

How to solve this issue?

Answer Source

localhost must be defined in your hosts file, which it is by default on Windows and most OSs.

Check the following text file and see what's up:


Please note "hosts" is the file, no extension, it's not a folder. This file should be pretty much empty, if you see entries either your AV/spam blocker added a ton of entries that point to or nasty malware has written garbage in there, despite, newer entries are below older ones. Localhost should be the first entry in that file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download