连接MySql速度慢的解决方法(skip-name-resolve)_MySQL
最近在Linux服务器上安装MySql5后,本地使用客户端连MySql速度超慢,本地程序连接也超慢。
解决方法:在配置文件my.cnf的[mysqld]下加入skip-name-resolve。
原因是默认安装的MySql开启了DNS的反向解析。如果禁用的话就不能在MySQL的授权表中使用主机名了而只能用ip格式。
附:How MySQL uses DNS
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 thread will lock a mutex and call gethostbyaddr() and gethostbyname() instead. Note that in this case no other thread can resolve other hostnames that is 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.
或者host中添加
192.168.1.21 N-21

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many friends complain about the slow download speed of Uplay, and the download speed of Uplay platform is too slow, sometimes only a few KB, so how to solve it? It's mainly a problem with some files. Let me give you the solution to the slow download speed of Uplay. Let's take a look at the details. Solution to the slow download speed of uplay 1. First press the shortcut key "win+r" to open run, and enter "control" to open the control panel. 2. Then click "View network status and tasks". 3. Click on your current network and select Properties. 4. Double-click to open "Internet Protocol Version 4 (TCP/ipv4)". 5. Check "Use the following dns server address" below and enter 11411411

Speaking of HeidiSQL software, I believe many users are familiar with it, but do you know how HeidiSQL connects to MySQL? The following content brings you the specific methods of HeidiSQL connecting to MySQL. Let’s learn together. 1. Click the New button and then modify the session name. 2. Enter the user and password, keep other options unchanged by default, and click the Save button to save this session. 3. Click the Open button. 4. Enter the database management interface, select the database, and click the query button. 5. Enter the query statement and click the execute button.

What should I do if Sogou Browser is very slow to open web pages? What should I do if Sogou Browser is too slow to open web pages when surfing the Internet? After using Sogou Browser for a long time, the speed of opening web pages becomes very slow. It takes a long time to load a web page. What should I do in this situation? In fact, it is easy to solve. We can clear the cache. It may be that there is too much cache garbage, causing the web page to freeze. The editor will introduce the solution steps when Sogou browser opens the web page very slowly. If not, follow me below. Take a look! What should I do if Sogou Browser is very slow to open web pages? 1. Open Sogou Browser, as shown in the figure below, click the first icon on the upper right to open the menu bar and click "Options" at the bottom. 2. At this time, you will enter the settings page of Sogou High-speed Browser.

Solving Common WordPress Errors: Analysis and Solutions to Slow Page Loading Speed With the rapid development of the Internet, websites have become an important tool for companies to display their image and attract users. However, the problem that comes with it is the slow loading speed of the website, especially websites built with WordPress. This article will help you solve the problem of slow loading speed of WordPress pages from the aspects of problem analysis and solution, combined with specific code examples. Problem analysis: Plug-in conflict: WordPress has

Many friends who have updated win11 find that their system download speed is very slow, but they don’t know what to do if win11 download speed is slow. In fact, this is because the download speed of Microsoft’s official website itself is very slow, so you can download it here. What to do if win11 download speed is slow: 1. Download win11 system is slow 1. If we want to download and install win11, it is slow. 2. It is most likely because of Microsoft's problem. Because Microsoft's servers are abroad, the download speed is slow. 3. For this reason, this site has downloaded the win11 system for you in advance. As long as you download it from us, the download speed will be faster. 4. The system downloaded from this site is also very convenient to install. Just double-click to open the downloaded file and find the "One-click installation system.exe" to install it. two

Learn JSP from scratch How to connect to MySQL database Preface JSP (JavaServerPages) is a dynamic web page technology that allows you to embed Java code in HTML pages. This allows you to create interactive and dynamic web pages such as shopping carts, online forms, and games. MySQL is a popular open source relational database management system (RDBMS). It is known for its speed, reliability and scalability. In this article, we will show you how to learn JSP from scratch

Common causes and solutions for slow PHP frameworks: ORM redundant queries: optimize queries, use indexes and unions, and enable ORM caching. Large view files: Explode view files, enable view caching, enable gzip compression. Too many third-party dependencies: only load necessary dependencies, use the optimizer to shrink dependencies, and use caching to reduce external API calls. Invalid routing: Use route caching, optimize routing configuration, and reduce nested routing and wildcard routing. Database connection issues: Use connection pools to manage connections, optimize queries, and consider using NoSQL databases or caching mechanisms.

Modifying the MySQL host name means changing the host name of the MySQL database server from the original value to the new value. This process requires a series of steps, including modifying the MySQL configuration file and restarting the MySQL service. The following will introduce the steps to modify the MySQL host name in detail and provide specific code examples. Step 1: Back up data. Before modifying the MySQL host name, be sure to back up important data in the database to prevent data loss due to unexpected situations. Step 2: Log in to MyS
