mysql版本5.7.26
导入sql文件时报错Got a packet bigger than ‘max_allowed_packet’ bytes
原因:
导入的数据大于系统的限制的最大包大小。即插入的数据太大了,因此需要更改MySQL的默认配置。
通过下面命令查看当前系统限制最大值,保存系统最大值,一会还要在改回来。
show variables like '%max_allowed_packet%' ;
修改系统最大值:
SET GLOBAL max_allowed_packet=150M;
如果使用上面命令无效,直接修改配置文件:
linux 系统,查找my.cnf命令
whereis my.cnf
修改my.cnf (文件一般在/etc下
vi /etc/my.cnf
在文件下添加max_allowed_packet=100M
[mysqld]
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8
max_allowed_packet=100M