最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

Mysql max_allowed_packet 修改

LINX-SQL ajiang-tuzi 4091浏览
[17-03-21 05:26:17][https://www.amazon.com/dp/B01I8SZI9S/
]>https://www.amazon.com/dp/B01I8SZI9S/
[标题] SNEER Premium 2016 Wireless Bluetooth Headset Stereo Sports/Running Earbuds Headphones for Iphone 6s Plus 5 SE 5S 5C, Ipad 2 3 4 New iPad,iPad Air Ipod,Smart Phones
[排名] 0
[图片] 82792ed47071a9616b562d0f2366eafa
[option_text] "selected_variations" : {"color_name":"DeepBlue"},
[option_color] DeepBlue
[option_size] N
[Currently unavailable]No
B01I2JX26E      https://www.amazon.com/dp/B01I2JX26E/
        1490086191.tmp.txt
N Title totla[0]
PHP Warning:  mysql_query(): MySQL server has gone away in C:\Users\Administrator\Desktop\GET\Mysql.php on line 43

Warning: mysql_query(): MySQL server has gone away in C:\Users\Administrator\Desktop\GET\Mysql.php on line 43
PHP Warning:  mysql_query(): Error reading result set's header in C:\Users\Administrator\Desktop\GET\Mysql.php on line 43

Warning: mysql_query(): Error reading result set's header in C:\Users\Administrator\Desktop\GET\Mysql.php on line 43
PHP Fatal error:  Uncaught exception 'Exception' with message '鏌ヨ?閿欒?MySQL server has gone away' in C:\Users\Administrator\Desktop\GET\Mysql.php:45
Stack trace:
#0 C:\Users\Administrator\Desktop\GET\skuList.php(499): Weicot\MySql::exe(' UPDATE order_p...')
#1 C:\Users\Administrator\Desktop\GET\skuList.php(644): loadPath('B01I2JX26E', 'https://www.ama...', '1490086191.tmp....', Object(Redis))
#2 {main}
  thrown in C:\Users\Administrator\Desktop\GET\Mysql.php on line 45

Fatal error: Uncaught exception 'Exception' with message '鏌ヨ?閿欒?MySQL server has gone away' in C:\Users\Administrator\Desktop\GET\Mysql.php:45
Stack trace:
#0 C:\Users\Administrator\Desktop\GET\skuList.php(499): Weicot\MySql::exe(' UPDATE order_p...')
#1 C:\Users\Administrator\Desktop\GET\skuList.php(644): loadPath('B01I2JX26E', 'https://www.ama...', '1490086191.tmp....', Object(Redis))
#2 {main}
  thrown in C:\Users\Administrator\Desktop\GET\Mysql.php on line 45

C:\Users\Administrator>php C:\Users\Administrator\Desktop\GET\skuList.php
继续上次任务
B00PHSBG26      https://www.amazon.com/dp/B00PHSBG26/
        1490086191.tmp.txt

mysql max_allowed_packet 设置过小导致记录写入失败
mysql根据配置文件会限制server接受的数据包大小。
有时候大的插入和更新会受max_allowed_packet 参数限制,导致写入或者更新失败。
查看目前配置

show VARIABLES like '%max_allowed_packet%';

显示的结果为:

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

| Variable_name      | Value   |

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

| max_allowed_packet | 1048576 |

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

以上说明目前的配置是:1M

修改方法

1、修改配置文件
可以编辑my.cnf来修改(windows下my.ini),在[mysqld]段或者mysql的server配置段进行修改。

max_allowed_packet = 20M

如果找不到my.cnf可以通过
mysql –help | grep my.cnf
去寻找my.cnf文件。
linux下该文件在/etc/下。
2、在mysql命令行中修改
在mysql 命令行中运行

set global max_allowed_packet = 2*1024*1024*10

然后退出命令行,重启mysql服务,再进入。

show VARIABLES like '%max_allowed_packet%';

查看下max_allowed_packet是否编辑成功

内容注意:该值设置过小将导致单个记录超过限制后写入数据库失败,且后续记录写入也将失败。
ps -aux | grep mysql
/usr/local/mysql/bin/mysqld_safe  --defaults-file=/usr/local/mysql/my.cnf --user=mysql & 

转载请注明:(●--●) Hello.My Weicot » Mysql max_allowed_packet 修改

蜀ICP备15020253号-1