The folks at Percona have benchmarked TCP/IP vs. Unix Connections to a local MySQL server.
When connecting to a local MySQL instance, you have two commonly used methods: use TCP/IP protocol to connect to local address –
localhost
or127.0.0.1
– or use Unix Domain Socket.If you have a choice (if your application supports both methods), use Unix Domain Socket as this is both more secure and more efficient.
Not that the exact numbers really matter, but the message should be clear: Use a Unix Domain Socket to connect, if you have the chance.
Need to Connect to a Local MySQL Server? Use Unix Domain Socket! →