MySql uses skip-name-resolve to solve the problem of slow external network connection client

MySql uses skip-name-resolve to solve the problem of slow external network connection client

The MySQL built on Tencent Cloud is always very slow when accessed using Navicat on the development computer. It turns out that Mysql will perform domain name resolution on the requested address. The development computer does not have a domain name, so it will be very slow. Use the following to solve it

[mysqld]
skip-name-resolve
skip-grant-tables

Official explanation

How MySQL
When a new thread connects to mysqld, mysqld will
spawn a new thread to handle the request. This thread will first check
if the hostname is in the hostname cache. If not the thread will call
gethostbyaddr_r() and gethostbyname_r() to resolve the hostname. If
The operating system doesn't support the above thread-safe calls, the
The thread will lock a mutex and call gethostbyaddr() and gethostbyname()
instead. Note that in this case no other thread can resolve other
hostnames that are not in the hostname cache until the first thread is
ready. You can disable DNS host lookup by starting mysqld with
–skip-name-resolve. In this case you can however only use IP names in
the MySQL privilege tables. If you have a very slow DNS and many
hosts, you can get more performance by either disabling DNS lookup
with –skip-name-resolve or by increasing the HOST_CACHE_SIZE define
(default: 128) and recompile mysqld. You can disable the hostname
cache with –skip-host-cache. You can clear the hostname cache with
FLUSH HOSTS or mysqladmin flush-hosts. If you don't want to allow
connections over TCP/IP, you can do this by starting mysqld with
--skip-networking.

According to the documentation, if your mysql host queries DNS very slowly or there are many client hosts, the connection will be very slow. Since our development machine cannot connect to the external network, DNS resolution is impossible to complete, which explains why the connection is so slow. At the same time, please note that after adding this configuration parameter, the host field in the MySQL authorization table cannot use the domain name but only the IP address, because this is the result of prohibiting domain name resolution.

Summarize

The above is what I introduced to you about MySql using skip-name-resolve to solve the problem of slow external network connection client. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Problems and solutions of error 08001 when linking to MySQL in IDEA and no table display after successful connection
  • After installing Navicat in MySQL, 2059 appears, Authentication plugin and local link virtual machine docker, remote link server
  • Python pymysql link database query results converted to Dataframe instance
  • Detailed explanation of MySQL multi-table query examples [link query, subquery, etc.]
  • Example operation MySQL short link
  • Summary of the installation process of MySql 8.0.11 and the problems encountered when linking with Navicat
  • Detailed explanation of the use of MySQL group links
  • How to use ssh tunnel to connect to mysql server
  • How to view MySQL links and kill abnormal links

<<:  How to view and clean up Docker container logs (tested and effective)

>>:  The whole process of node.js using express to automatically build the project

Recommend

React method of displaying data in pages

Table of contents Parent component listBox List c...

Using CSS3's 3D effects to create a cube

Learning to use CSS3's 3D effects to create a...

JavaScript built-in date and time formatting time example code

1. Basic knowledge (methods of date objects) 😜 ge...

Vue implements file upload and download

This article example shares the specific code of ...

How to use Webstorm and Chrome to debug Vue projects

Table of contents Preface 1. Create a new Vue pro...

A few experiences in self-cultivation of artists

As the company's influence grows and its prod...

How to bind Docker container to external IP and port

Docker allows network services to be provided by ...

Unity connects to MySQL and reads table data implementation code

The table is as follows: Code when Unity reads an...

HTML (css style specification) must read

CSS style specifications 1. Class Selector 2. Tag...

MySQL 5.7 and above version download and installation graphic tutorial

1. Download 1. MySQL official website download ad...

How to use SVG icons in WeChat applets

SVG has been widely used in recent years due to i...

Vue implements a simple shopping cart example

This article shares the specific code of Vue to i...

How to use glog log library in Linux environment

Generate Linux library The Linux version uses cen...

jQuery implements simple pop-up window effect

This article shares the specific code of jQuery t...