当前位置:网站首页>[step by step, even thousands of miles] MySQL reports a large number of unauthenticated user connection errors
[step by step, even thousands of miles] MySQL reports a large number of unauthenticated user connection errors
2022-04-23 06:58:00 【Sebastien23】
【 Every step is worth a thousand miles 】MySQL A large number of papers unauthenticated user Connection error
The problem background
Application newspaper MySQL Database cannot connect , After investigation, it is found that the number of connections is full . adopt max_connections
Parameter to increase the upper limit of connections to 1000 after , The database began to report a lot unauthenticated user error .
: 343942 : unauthenticated user : 192.168.0.4:49607 : : Connect : : login :
: 343943 : unauthenticated user : 192.168.0.4:49608 : : Connect : : login :
...
...
Problem analysis
I checked it on the Internet , It may be because the database is not configured skip-name-resolve
Parameters ,MySQL The host name will be resolved when verifying the application connection , If there are too many connections and they are not released in time , It will lead to MySQL“ Feign death ”, Thus the above situation appears .
MySQL The official response to skip-name-resolve
The parameters are described as follows :
Whether to resolve host names when checking client connections. If this variable is OFF, mysqld resolves host names when checking client connections. If it is ON, mysqld uses only IP numbers; in this case, all Host column values in the grant tables must be IP addresses.
namely , When this parameter is turned off ,MySQL The host name will be resolved when checking the client connection ; When this parameter is turned on ,MySQL Only check IP.
Checked the problem MySQL Profile of the database , There is really no skip-name-resolve
This business . You can also execute the following statement to query , See if the value is OFF:
show variables like 'skip_name_resolve';
MySQL When the official application connects to the database DNS The parsing process is described as follows :
For each applicable new client connection, the server uses the client IP address to check whether the client host name is in the host cache. If so, the server refuses or continues to process the connection request depending on whether or not the host is blocked. If the host is not in the cache, the server attempts to resolve the host name. First, it resolves the IP address to a host name and resolves that host name back to an IP address. Then it compares the result to the original IP address to ensure that they are the same. The server stores information about the result of this operation in the host cache. If the cache is full, the least recently used entry is discarded.
namely , When the database verifies a new application connection , Will be will be IP Address resolved to hostname , Then resolve the host name to IP, And original IP compare . If DNS Server problem , It is also possible to report unauthenticated user Error of .
Problem handling
Method 1
stay MySQL Add the following line to the configuration file , Then restart the database .
skip-name-resolve
The advantage is that it can fundamentally solve the problem ; The disadvantage is that when authorizing users in the future host Only use IP Address , Cannot use hostname .
Method 2
Manually configure... For each application connection hosts analysis . such as Linux Operating system , Can be in /etc/hosts
Add corresponding host Record . The disadvantage is that it is not applicable to the case where there are too many application connections .
192.168.32.33 appserver01
192.168.32.34 appserver02
References:
【1】https://dev.mysql.com/doc/refman/5.7/en/host-cache.html
【2】https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html
版权声明
本文为[Sebastien23]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230557416266.html
边栏推荐
猜你喜欢
随机推荐
tc ebpf 实践
memcached 源码分析
The getfield () method in TP5 changes, and TP5 gets the value of a single field
rdma网络介绍
Offset et client pour obtenir des informations sur l'emplacement des éléments Dom
Jenkins搭建与使用
Usage of if conditional statements in SQL
Batch modify / batch update the value of a field in the database
ES6 specification details
ES入门学习笔记
[OSS file upload quick start]
如何使用TiUP部署一个TiDB v5.0集群
MySQL【sql性能分析+sql调优】
redis 实践笔记和源码分析
JS realizes modal box dragging
TP5中的getField()方法变化,tp5获取单个字段值
JS手写兼容性事件绑定
JS implementation of web page rotation map
Centos8 builds php8 0.3 operating environment
【代码解析(5)】Communication-Efficient Learning of Deep Networks from Decentralized Data