The Difference Between and Localhost

Most of the time it doesn’t make a difference what you use, “localhost” or It turns out that it does make a somehow big difference when connecting to a mysql server.

If you use “localhost” most clients will try to “connect” via the socket file that the server puts, if it adheres to the standard, into /tmp, if you use a IP connection is made.

I was made aware of this fact when I tried to connect to the mysql server that comes with XAMP. Its configuration does not adhere to the standard and puts the socket file into /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock on OSX.

The clients that wasn’t aware of this fact obviously failed to connect and threw the error: “Connect Error: SQLSTATE[HY000] [2002] No such file or directory” when a connection attempt was made. Hope who ever has the same problem finds this and spends less time debugging then I did 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.