mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法

向mysql数据库中导入sql文件时,如果文件过大(几百M),会提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”

mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法

mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法

1.查看目前数据库配置

show VARIABLES like '%max_allowed_packet%';

显示如下结果

+--------------------+---------+

| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
说明目前的配置是:1048576/1024/1024 = 1M
 
2.修改my.ini文件中“max_allowed_packet”的值
路径在mysql的安装目录中
mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法

mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法

3.修改后,重启mysql服务

在cmd窗口下,先执行net stop mysql;再执行net start mysql

然后再到sqlyog中执行show VARIABLES like '%max_allowed_packet%';发现值已更改

mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法

上一篇:python(1) - 字符串


下一篇:MySQL数据库索引简介