使用mysql数据库,包含视图和存储过程,使用navicat导库生成的脚本会有一些问题,所以使用SQLyog工具导库。
生成的脚本文件大小到1G,导入的时候会遇到一些问题,这里总结一下。
1、MySQL server has gone away
出现这个问题是因为查询语句太长。
因为mysql客户端和服务器间的通信是半双工的,意思是任何时刻,要么是客户端向服务器发数据,要么是服务器向客户端发数据,无法将一个消息切成小块独立发送。
客户端用一个单独的数据包将查询传给服务器。
max_allowed_packet 参数 最大允许的包大小,修改这参数就可以了。
解决方法语句如下:
set global max_allowed_packet=1024*1024*16;
值可以自己调。我目前一次插入十几万条数据的insert语句用这个配置没有问题。这个设置方法在mysql重启后会变回默认值。
查看当前的值:
show global variables like 'max_allowed_packet';
2、ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)
这个解决方法是 :
set global log_bin_trust_function_creators=TRUE;
同样在mysql重启后需要重新设置。
3、Error Code: 1197 - Multi-statement transaction required more than ‘max_binlog_cache_size’ bytes of storage; increase this mysqld variable and try again
这个解决方法是 :
set global max_binlog_cache_size = 600000000;
值可以自己调。我设置的有点大。
查看当前值的方法:
show session variables like 'max_binlog_cache_size';
在mysql重启后需要重新设置。