mysql unauthenticated user原因分析以及解决方法
2013-02-28 21:04
681 查看
今天OJ数据库服务器挂了,我这边很奇怪的ssh连不上,后来连上了但是很卡,看了下mysql/error.log没看出来什么原因。学长那边进去mysql用了下showprocesslist发现大量的unauthenticated user Connect的信息。于是查了一下原因。
手册中的解释是: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。意即:有一个线程在处理客户端的连接,但是该客户端还没通过用户验证
MySQL处理用户连接时进行如下过程来验证用户的合法性:
即:先作反向解析IP>Hostname,然后作Hostname>IP的正向解析。如果结果符合,则验证为合法用户允许登录,如果不符合则定义为“unauthenticated user”。
原因可能有:
1、服务器在做DNS反响解析,解决办法有两个:
1-)在 hosts 中添加客户端ip,如
192.168.0.1 yejr
2-) MySQL启动参数增加一个skip-name-resolve,即不启用DNS反响解析。即修改mysql配置文件/etc/mysql/my.cnf,在 [mysqld] 行下添加 –skip-name-resolve ,重新启动mysql服务
2、服务器的线程还处于排队状态,因此可以加大 back_log
采用第二个方法成功了。
建议创建用户权限的时候,不要使用hostname作为限制而是直接用IP;更干脆的话就主机不配置DNS Server
手册中的解释是: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。意即:有一个线程在处理客户端的连接,但是该客户端还没通过用户验证
MySQL处理用户连接时进行如下过程来验证用户的合法性:
When a new client connects to mysqld, mysqld spawns a new thread to handle the request. This thread first checks whether the host name is in the host name cache. If not, the thread attempts to resolve the host name: The thread takes the IP address and resolves it to a host name (using gethostbyaddr()). It then takes that host name and resolves it back to the IP address (using gethostbyname()) and compares to ensure it is the original IP address.
即:先作反向解析IP>Hostname,然后作Hostname>IP的正向解析。如果结果符合,则验证为合法用户允许登录,如果不符合则定义为“unauthenticated user”。
原因可能有:
1、服务器在做DNS反响解析,解决办法有两个:
1-)在 hosts 中添加客户端ip,如
192.168.0.1 yejr
2-) MySQL启动参数增加一个skip-name-resolve,即不启用DNS反响解析。即修改mysql配置文件/etc/mysql/my.cnf,在 [mysqld] 行下添加 –skip-name-resolve ,重新启动mysql服务
2、服务器的线程还处于排队状态,因此可以加大 back_log
采用第二个方法成功了。
建议创建用户权限的时候,不要使用hostname作为限制而是直接用IP;更干脆的话就主机不配置DNS Server
相关文章推荐
- MySQL出现Waiting for table metadata lock的原因以及解决方法
- MySQL This function has none of DETERMINISTIC, NO SQL...错误1418 的原因分析及解决方法
- mysql服务器查询慢原因分析与解决方法小结
- 安装SQL Server 2012过程中出现“启用windows功能NetFx3时出错”(错误原因、详细分析及解决方法)以及在Windows Server2012上安装.NET Framework 3.5的详细分析及安装过程
- MySQL出现Waiting for table metadata lock的原因以及解决方法
- mysql服务器查询慢原因分析与解决方法小结
- 常见邮件发送失败原因分析以及解决方法
- 分析电脑死机的常见的几种原因,以及对应的解决方法
- mysql服务器查询慢原因分析与解决方法小结
- Mac使用mysql中出现ERROR 1045: Access denied for user: 'root@localhost' 以及密码过期解决方法
- MySQL This function has none of DETERMINISTIC, NO SQL...错误原因分析及解决方法
- 记一次mysql死锁的原因分析和解决方法
- Mysql中Check约束无效的原因以及解决方法
- Win7系统删除文件提示“文件名过长”怎么办?原因分析以及解决方法
- tomcat内存溢出原因分析与解决以及java内存溢出、栈溢出的原因与排查方法
- MySQL 错误1418 的原因分析及解决方法
- MySQL 错误1418 的原因分析及解决方法
- MySQL This function has none of DETERMINISTIC, NO SQL...错误1418 的原因分析及解决方法
- mysql服务器查询慢原因分析与解决方法
- Mac使用mysql中出现ERROR 1045: Access denied for user: 'root@localhost' 以及密码过期解决方法