环境:
MySQL 5.7.17
问题现象:
在启动mysqld进程一小段时间之后,执行连接MySQL数据库报错:
ERROR 2013 (HY000): Lost connect to MySQL server at 'waiting for initial communication packet', system error: 110
在什么都没有做的情况下,过一段时间再次尝试连接,就没问题了。
问题分析与解决:
通过查看mysql的错误日志,可以发现一个关键的信息 "ready for connections." 这个信息的出现表示MySQL可以连接了。再往前看,发现信息 "Beginning of list of non-natively partitioned tables" 和 "End of list of non-natively partitioned tables" 之间的间隔较长,消耗了最长的时间。如果在这期间连接数据库,就会报出上面的错误来。
这个现象在下面的链接中有解释,解决的办法是在启动mysqld的时候,加上一个参数 --disable-partition-engine-check
https://bugs.mysql.com/bug.php?id=85830
However, this check might take a very long time see below (almost 20 minutes):
2017-04-06T11:34:51.070461Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
2017-04-06T11:34:51.070478Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-04-06T11:53:41.730694Z 0 [Note] End of list of non-natively partitioned tables
The logs above have been produced on this system: