今天mysql从一个mysql库中导入另一个mariadb库中是总是报:
ERROR 2006 (HY000) at line 176 in file: 'xxx.sql': MySQL server has gone away
但我是在当前服务器上导入的不可能是网络问题。
解决方法
后来按如下方法解决了问题:
1.去掉导入的xxx.sql中开头的注释
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
2.设置max_allowed_packet大小
mysql> set global max_allowed_packet=1024*1024*16;
mysql> show global variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+
1 row in set (0.00 sec)
参考地址:
https://blog.csdn.net/smd2575624555/article/details/88124067
https://www.jb51.net/article/23781.htm
转载请注明来源:https://www.cnblogs.com/bugutian/