mysql在导入大数据库的时候,报错 Unknown MySQL server host ... ERROR: Can't connect to the server No connection. Trying to reconnect...

时间:2021-08-03 15:18:16

 

或者,报错信息:


ERROR 2005 (HY000): Unknown MySQL server host '10997107101114' (0)
ERROR:
Can't connect to the server

No connection. Trying to reconnect...

=======================

尝试了几种解决办法:

(1)

mysql> show global variables like 'max_allowed_packet';

mysql> set global max_allowed_packet=1024*1024*16;

mysql> show global variables like 'max_allowed_packet';

 

mysql在导入大数据库的时候,报错 Unknown MySQL server host ... ERROR: Can't connect to the server No connection. Trying to reconnect...

重新导入数据库,还是会发生上面的问题

 

(2)把 localhost 改成 127.0.0.1 再试试,结果还是失败。

即把 mysql -uroot -p 

改成

mysql -uroot -h127.0.0.1 -p

还是不行。

 

 (3)修改Mysql的配置文件my.ini

max_allowed_packet = 640M

 

=======================

unknown command '\n' 这种导入数据库的时候,会发生这个错误,有关系吗?

mysql在导入大数据库的时候,报错 Unknown MySQL server host ... ERROR: Can't connect to the server No connection. Trying to reconnect...

 

      DOS报错error at line XXX:unknown command '\n'
         

这种情况一般是字符集不对应引起的,如果数据库是utf8编码,则
         mysql导入的时
         mysql -uroot -ppasswd <d:\aa.sql --default-character-set=utf8
         同样如果数据库是gbk,则导入时
         mysql -uroot -ppasswd <d:\aa.sql --default-character-set=gbk