MySQL UNIX socket

less than 1 minute read

When using phpMyAdmin earlier today I noticed it was connected to MySQL through an UNIX socket.

UNIX sockets are faster than TCP/IP connections and if there is an UNIX socket and a TCP/IP connection available the UNIX socket should be selected by default (when using localhost as host).

However, how can you be sure this is the case?

If you only use your MySQL server locally you can force MySQL to only create a UNIX socket by adding skip-networking to your my.cnf. I also commented out bind-address =, just in case.

Restart your MySQL server and check if MySQL is not listening on TCP/IP anymore by executing netstat -a.

Now check if all your websites/applications can still access your MySQL server and you’re done.


Leave a comment