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
"Unix sockets" are not TCP/IP sockets. They are always limited to the current system only – it is not possible to connect to another system's socket over the network. Because of that, the hostname localhost is special in MySQL and the client doesn't actually attempt to look up its IP address at all.
MySQL manages connections to the database server through the use of a socket file, a special kind of file that facilitates communications between different processes. The MySQL server's socket file is named mysqld. sock and on Ubuntu systems it's usually stored in the /var/run/mysqld/ directory.
The default MySQL port 3306 is TCP (Transmission Control Protocol).
It turns that I saved the file as my.conf
, witch it should be my.cnf
, and that is why the server was only load and use the default configuration.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With