问题原文
原帖链接 · Houman · CC BY-SA 4.0
I'm trying to disable the DNS name resolving as I have many other servers connecting to the central database. The DNS resolving is slow and can apparently be disabled like this:
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
port=3412
max_connections=500
skip-name-resolve
However I still can connect to it via localhost, which doesn't make sense to me.
mysql -h localhost -u root -p -P 3412
I have done some research here:
If you choose to use skip-name-resolve, make sure your MYSQL connection privileges are set to allow IPs, and not hosts.
On most systems, for the local MySQL Server you will need to use host=127.0.0.1 for ipv4 and host=::1 for ipv6 networks, instead of the classic “host=localhost”.
Why can I still connect via localhost if DNS resolving is disabled?
已采纳解答
原帖链接 · Michael Hampton · CC BY-SA 4.0
MySQL treats connecting to localhost specially. In this case it connects via a UNIX domain socket, not via TCP, and the string localhost is still used for user authentication.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
