Force MySQL to use only unix socket

SIFE picture SIFE · Mar 11, 2013 · Viewed 14k times · Source

I want my MySQL server to only use unix socket, and ignore the TCP networking, so I added this line to my configuration /etc/my.cnf:

skip-networking 

But netstat show me that MySQL still using TCP port 3306:

# netstat -tl | grep mys
tcp        0      0 *:mysql      *:*                         LISTEN 

Answer

arielf picture arielf · Mar 11, 2013

If the reason is to prevent remote access, you can achieve your goal by having:

bind-address = 127.0.0.1

in the [mysqld] section of your my.cnf and restarting mysqld.

This ensures that mysqld would allow only local connections.

To prevent remote-access skip-networking is not the only option, as the comments in (2013) my.cnf say:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.

EDIT: The secure version (with the bind address above) is already the default in recent (as of 2013) Ubuntu versions, so you have to change it (comment the line above out) only if you actually want to enable remote serving.