MySQL远程连接丢失问题解决方法 Lost connection to MySQL server at ‘reading initial communication packet
1、检查防火墙
systemctl status firewalld
systemctl stop firewalld
2、mysql用户权限问题
mysql -u root -p -h 127.0.0.1
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql>
mysql>
mysql> GRANT ALL PRIVILEGES ON bcm.* TO 'root'@'%';
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL PRIVILEGES ON bcm_middleware.* TO 'root'@'%';
Query OK, 0 rows affected (0.07 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)