mysql出现大量连接unauthenticated user

连接如下:
| 2951604 | unauthenticated user | 192.168.1.21:37387 | NULL | Connect | NULL | Reading from net | NULL |
| 2951605 | unauthenticated user | 192.168.1.30:56640 | NULL | Connect | NULL | Reading from net | NULL |
| 2951606 | unauthenticated user | 192.168.1.20:42519 | NULL | Connect | NULL | Reading from net | NULL |
| 2951607 | unauthenticated user | 192.168.1.131:59521 | NULL | Connect | NULL | Reading from net | NULL |
| 2951608 | unauthenticated user | 192.168.1.131:59522 | NULL | Connect | NULL | Reading from net | NULL |
| 2951609 | unauthenticated user | 192.168.1.131:59523 | NULL | Connect | NULL | Reading from net| NULL |

看下手册中的解释是:
unauthenticated user refers to a thread that has become associated with a client connection but for which authentication of the client user has not yet been done。
即:有一个线程在处理客户端的连接,但是该客户端还没通过用户验证。

原因可能有:
a、服务器在做DNS反响解析,解决办法有2个:
1、在 hosts 中添加客户端ip,如
192.168.1.18 web1
2、MySQL启动参数增加一个skip-name-resolve,即不启用DNS反响解析
b、服务器的线程还处于排队状态,因此可以加大 back_log
back_log为只读参数 需要重启mysql服务
back_log定义mysql在暂时停止回答请求之前的短时间内多少请求可以被存在堆栈中。
如果期望在端时间内有很多连接,则需要增加它
换句话说,就是该值定义了TCP/IP连接侦听队列的大小
操作系统在这个队列大小上有它自己的限制,视图设定back_log高于操作系统的限制将是无效的。
在mysql中的back_log的设置取决于操作系统,
在Linux下这个参数的值不能大于系统参数tcp_max_syn_backlog的值
通过以下命令可以查看当前值:cat /proc/sys/net/ipv4/tcp_max_syn_backlog
通过以下命令进行修改sysctl -w net.ipv4.tcp_max_syn_backlog=n

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注