最近重启服务器的 MySQL 总是报大量的如下错误:
160330 9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 139 user: ‘root‘
160330 9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 138 user: ‘root‘
160330 9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 137 user: ‘root‘
160330 9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 136 user: ‘pdss‘
160330 9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 131 user: ‘root‘
160330 9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 130 user: ‘csm‘
这个错误其实是 MySQL 在对 DNS 做反查,由于反查的接续速度过慢,大量的查询处理不及时,线程得不到释放,造成 MySQL 「假死」。
修改 MySQL 的配置文件 my.cnf
在 [mysqld] 下添加:
skip-name-resolve
修改 MySQL 的配置文件 my.ini
在 [mysqld] 下添加:
skip-locking
skip-name-resolve
修改完成后,重启 MySQL 服务即可。