Is there a legitimate reason to use Unix sockets over TCP / IP with mysql?

I am trying to understand why mysql uses the default Unix socket (/tmp/mysql.sock) instead of regular TCP / IP sockets.

This doesn't sound like security, since you can only listen to 127.0.0.1, which should be equally safe (the socket file is writable in the world, so you don't get protection based on Unix accounts).

And, of course, all operating systems rely on high-performance TCP / IP so much that it cannot be significantly slower than Unix sockets. Linux does all kinds of zero-copy tricks even for network traffic, so it should certainly be fast for loopback.

So, is there a legitimate reason to use Unix sockets here, or is it just some weird historical case?

+5
source share
2 answers

As long as you do not get into the entire IP stack when navigating to the local host, you will still get to most of it. The UNIX connector is essentially just a two-way pipe. It is faster and easier.

Unix sockets also allow you to control access without managing firewall rules, since access can be granted through file system permissions.

Another feature provided by unix sockets is the ability to transfer a file descriptor from one process to another.

+8
source

Unix Sockets TCP/IP , , , . . wikipedia.

Unix , , . UNIX , inodes . . ( ) , .

+6

All Articles