Also have a look inside the mysql database which defines the user access privileges. You can define there from which source hosts a given user is allowed to connect. You can consult http://dev.mysql.com/doc/refman/5.1/en/connection-access.html for more details
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:
C:\WINDOWS\system32\drivers\etc\hosts
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 127.0.0.1 or nasty malware has written garbage in there, despite, newer entries are below older ones. Localhost should be the first entry in that file.
If MySQL connects to 127.0.0.1 it does so via TCP/IP whereas if it connects to localhost it does so via a socket.
Is PHP looking in the right place for mysql.sock? Make sure php.ini and my.conf have matching locations
Connect to MySQL using localhost instead of 127.0.0.1 on a MAC. For a long while now I’ve been connecting to MySQL on my development platform with 127.0.0.1 because for some reason localhost didn’t work. Turns out it’s because 127.0.0.1 uses TCP/IP and localhost uses sockets. The php.ini file points to the wrong place for the mysql.sock so all you have to do is change it, restart apache and voila!
Open php.ini: /private/etc/php.ini
Find the following line: mysql.default_socket = /var/mysql/mysql.sock
Replace with: mysql.default_socket = /tmp/mysql.sock
Restart apache: apachectl restart
Note: Depending on your setup, you may also have to update these lines in your php.ini:
Also have a look inside the mysql database which defines the user access privileges. You can define there from which source hosts a given user is allowed to connect. You can consult http://dev.mysql.com/doc/refman/5.1/en/connection-access.html for more details
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 127.0.0.1 or nasty malware has written garbage in there, despite, newer entries are below older ones. Localhost should be the first entry in that file.
Try:
IE-->Tools-->Options--> Connection --> LAN Settings Check Bypass Proxy for local addresses
If MySQL connects to 127.0.0.1 it does so via TCP/IP whereas if it connects to localhost it does so via a socket.
Is PHP looking in the right place for mysql.sock? Make sure php.ini and my.conf have matching locations
If you not on windows also test if mysql is connecting via socket, locally it normally does.
Force tcp with the mysql client
vs. socket (default on linux)
The latter didn't work for my
someone@127.0.0.1
For macs, here's the solution:
Connect to MySQL using localhost instead of 127.0.0.1 on a MAC. For a long while now I’ve been connecting to MySQL on my development platform with 127.0.0.1 because for some reason localhost didn’t work. Turns out it’s because 127.0.0.1 uses TCP/IP and localhost uses sockets. The php.ini file points to the wrong place for the mysql.sock so all you have to do is change it, restart apache and voila!
Note: Depending on your setup, you may also have to update these lines in your php.ini:
Note: If you don’t have a php.ini file, you need to copy the provided default called php.ini.default
via http://madproject.com/general/connect-to-mysql-using-localhost-instead-of-127-0-0-1-on-a-mac/