Home > Database > Mysql Tutorial > body text

MySQL使用DNS的过程_MySQL

WBOY
Release: 2016-06-01 13:38:34
Original
1709 people have browsed it

bitsCN.com


MySQL使用DNS的过程

 

 当 mysql 客户端连接 mysql 服务器 (进程为:mysqld),mysqld 会创建一个新的线程来处理该请求。该线程先检查是否主机名在主机名缓存中。如果不在,线程试图解析主机名。

 

    如果系统是线程安全的,则 gethostbyaddr_r () 和 gethostbyname_r() 被调用,来执行主机名解析;    

 

    如果系统不支持线程安全调用,则线程会锁定一个互斥体并调用 gethostbyaddr() 和 gethostbyname() 。在这种情况下,在第1个线程解锁互斥体前,没有其它线程可以解析不在主机名缓存中的主机名。

 

    通过 --skip-name-resolve 选项启动 mysqld 来禁用DNS主机名查找。此时,只可以使用 MySQL 授权表中的 IP 地址,不能使用主机名。

 

    如果 DNS 解析很慢且包括许多主机,通过用--skip-name-resolve 禁用DNS查找或增加HOST_CACHE_SIZE定义(默认值:128)并重新编译mysqld来提高性能;

 

    通过 --skip-host-cache 选项启动服务器来禁用主机名缓存。要想清除主机名缓存,执行 FLUSH HOSTS 语句或执行 mysqladmin flush-hosts 命令。

 

    如果要完全禁止 TCP/IP 连接,用 --skip-networking 选项启动 mysqld 。

 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!