关注公众号
查看最新内容

mysql报错[Warning] IP address ‘xxxx’ could not be resolved: Name or service not known错误解决

一 原因

mysql日志显示[Warning] IP address ‘xxxx’ could not be resolved: Name or service not known

那是因为mysql默认会反向解析DNS,对于访问者Mysql不会判断是hosts还是ip都会进行dns反向解析,频繁地查询数据库和权限检查,这大大增加了数据库的压力,导致数据库连接缓慢,严重的时候甚至死机,出现“连接数据库时出错”等字样。

二 解决办法

禁用dns反查即可

进入/etc 找到mysql的配置文件my.cnf(linux环境下)或者my.ini(windows环境下)进行编辑加入如下一行即可:

[mysqld]
skip-name-resolve

创作不易,转载请注明出处:小风博客 » mysql报错[Warning] IP address ‘xxxx’ could not be resolved: Name or service not known错误解决