Wishlist 0 ¥0.00

mysql max_allowed_packet查询和修改

工作中经常需要导入或者导出较大的sql文件。导出时一般没问题,但在导入到其它Mysql库中,可能会出现“Packet for query is too large (1706 > 1024). You can change this value on the server by setting the max_allowed_packet' variable. ”或者程序(如python里面executemany)在插入大量数据时出现"MySQL server has gone away"。这些错误都可能是Mysql的mysql max_allowed_packet默认值太小。修改该值一般游两种方式。

方式一:sql语句修改

  1、首先登陆mysql查看当前该值的大小。

    show variables like '%max_allowed_packate%'

     2、修改其大小为1G

           set global max_allowed_packet = 1024*1024*1024

  这种修改方式修改后,需要重新登陆Mysql查看,才能看到修改后的值。并且,这种方式修改的mysql max_allowed_packet,在Mysql重启后,可能失效。

方式二:my.ini修改

  1、在my.ini文件中添加如下语句。比如:改为1G.如下图所示。修改完成后,需要重启mysql。

  


注意:方式2中max_allowed_packed一定是添加在【mysqld】才能生效。

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.