#2006 - MySQL server has gone away

#2006 - MySQL server has gone away

对于web应用来说,经常会用到mysql,而数据的备份与还原是web应用经常做的事,一般来说,用客户端工具phpmyadmin,sqlyog 等,来备份数据库没有任何问题,还原时经常碰到mysql提示的#2006错误。

Error: 2006 (CR_SERVER_GONE_ERROR)

Message: MySQL server has gone away

原因可能是sql语句过长,超过mysql通信缓存区最大长度;

调整mysql配置文件中max_allowed_packet

mysql配置文件mysql ini(部分)

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:\mysql\data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password	= your_password
port		= 3306
socket		= /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[wampmysqld]
#mysql端口
port		= 3306
socket		= /tmp/mysql.sock
#索引缓存区,决定你索引查询时能访问速度
key_buffer_size = 16M
#通信缓存区最大长度,决定你sql语句中字符串最大长度
max_allowed_packet = 1M
#排序缓存区,决定你orderby的速度
sort_buffer_size = 512K
#通信缓存区大小,查询时默认该值为通信缓存区大小,若不够会自动增加直到达到max_allowed_packe
net_buffer_length = 8K

read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
时间: 2024-11-03 21:00:48

#2006 - MySQL server has gone away的相关文章

mysql error: (2006, 'MySQL server has gone away')

max_allowed_packet=16M wait_timeout=400000 interactive_timeout = 400000 vim /etc/my.cnf  mysqld 中加入上面的内容. mysql error: (2006, 'MySQL server has gone away')

(2006, ‘MySQL server has gone away‘)

django 中,导入excel到mysql中.excel 转成sql,然后导入mysql. sql过大,出现(2006, 'MySQL server has gone away')错误. 改mysql 配置my.cnf,[mysqld]中的 max_allowed_packet = 64M ait_timeout = 86400 解决.

[Err] 2006 - MySQL server has gone away

1.错误描述 [Err] 2006 - MySQL server has gone away 2.错误原因 在将数据库脚本利用MySQL客户端导入时,出现这个错误:结果查明,由于脚本中的insert语句过多,插入数据量过大,导致MySQL客户端和服务器连接断开 3.解决办法 (1)修改MySQL配置文件my.ini 设置max_allowed_packed参数 (2)查看MySQL连接是否超时 (3)查看服务是否中断 版权声明:本文为博主原创文章,未经博主允许不得转载.

MySQL导入sql脚本错误:2006 - MySQL server has gone away

下面我给各位同学介绍在mysql中导入数据库时提示MySQL server has gone away问题的解决方法,如果你碰到mysql提示MySQL server has gone away错误我们可进入参考. 到如一些小脚本很少报错,但最近导入一个10+M的SQL脚本,却重复报错: Error occured at:2014-03-24 11:42:24Line no.:85Error Code: 2006 - MySQL server has gone away 最终找到原因,原来是My

[django1.6]跑批任务错误(2006, 'MySQL server has gone away')

有个django的定时任务,调用django的orm来对数据库进行数据处理. 在交互环境下直接启动pyhton脚本没有问题,放在定时任务中时候,总是出现 (2006, 'MySQL server has gone away') 的错误,开始以为是定时框架外部调用的问题,但是后来想想也不合理,为啥直接在shell中调用就没错呢, 想到django1.6的一些数据库连接的新属性(例如持久化连接等)会不会有影响,于是google了下. 看到django官网上有人提过这个类似于bug的东西: https

ThinkPHP出现General error: 2006 MySQL server has gone away的解决方法

错误: #13 {main}SQLSTATE[HY000]: General error: 2006 MySQL server has gone awayFILE: \ThinkPHP\Library\Think\Db\Driver.class.php(169) 原因分析: 本次错误提示是在cli模式运行,隔一段时间就会出现,查询资料后发现mysql默认没隔8个小时(2880000秒)就会断开 解决方案,解决方式找了三个 方法1 配置mysql.cnf(windows系统则是my.ini),指定

mysql导入大批量数据时,出现ERROR : (2006, 'MySQL server has gone away')

mysql导入数据时,出现ERROR : (2006, 'MySQL server has gone away') 解决方案:官方解释是适当增大 max_allowed_packet 参数可以使client端到server端传递大数据时,系统能够分配更多的扩展内存来处理. 设置 max_allowed_packet = 256M (1024*1024*256) set global max_allowed_packet=268435456; 使用set global命令修改 max_allowe

SQLyog恢复数据库报错解决方法【Error Code: 2006 - MySQL server has gone away】

https://blog.csdn.net/niqinwen/article/details/8693044 导入数据库的时候 SQLyog 报错了 Error Code: 2006 – MySQL server has gone away 搜了下,说是max_allowed_packet (MySQL的一个参数)设置的值不够大. 那我改下就行了 嘿嘿 In Windows: In the MySQL server installation directory,in my.ini file, a

Yii2 解决2006 MySQL server has gone away问题

Yii2 解决2006 MySQL server has gone away问题 Yii2版本 2.0.15.1 php后台任务经常包含多段sql,如果php脚本执行时间较长,或者sql执行时间较长,经常会碰到mysql断连,报2006 MySQL server has gone away错误.通常,mysql断连了,重连数据库就好了,但是在哪里执行重连呢?这是一个值得思考的问题. 手动重连 最直接的解决办法,是在执行较长sql,或者脚本执行合适的时机,手动重连 \Yii::$app->db->