Ways to use DNS in MySQL

Source: Internet
Author: User
Tags flush ip number mutex thread

When a new client connects to Mysqld, Mysqld creates a new thread to process the request. The thread first checks whether the host name is in the hostname cache. If not, the thread attempts to resolve the host name:

If the operating system supports thread-safe gethostbyaddr_r () and Gethostbyname_r () calls, threads use them to perform host name resolution.

If the operating system does not support thread-safe calls, the thread locks a mutex and invokes gethostbyaddr () and gethostbyname (). In this case, before the 1th line threads unlocked the mutex, no other thread can resolve the host name that is not in the host name cache.

You can disable DNS host name lookup by starting mysqld with the--skip-name-resolve option. In this case, however, you can only use the IP number in the authorization table in MySQL.

If you have a very slow DNS and many hosts, you can improve performance by disabling DNS lookups with--skip-name-resolve or by adding host_cache_size definitions (default: 128) and recompiling mysqld.

You can use the--skip-host-cache option to start the server to disable host name caching. To clear the host name cache, execute the FLUSH hosts statement or execute the mysqladmin flush-hosts command.

If you want to completely disable TCP/IP connections, start the mysqld with the--skip-networking option.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.