#2006 - MySQL server has gone away
來(lái)源:程序員人生 發(fā)布時(shí)間:2014-10-07 08:00:00 閱讀次數(shù):3581次
#2006 - MySQL server has gone away
對(duì)于web應(yīng)用來(lái)說(shuō),經(jīng)常會(huì)用到mysql,而數(shù)據(jù)的備份與還原是web應(yīng)用經(jīng)常做的事,一般來(lái)說(shuō),用客戶端工具phpmyadmin,sqlyog 等,來(lái)備份數(shù)據(jù)庫(kù)沒有任何問題,還原時(shí)經(jīng)常碰到mysql提示的#2006錯(cuò)誤。
Error: 2006
(CR_SERVER_GONE_ERROR
)
Message: MySQL server has gone away
原因可能是sql語(yǔ)句過長(zhǎng),超過mysql通信緩存區(qū)最大長(zhǎng)度;
調(diào)整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:mysqldata) 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
#索引緩存區(qū),決定你索引查詢時(shí)能訪問速度
key_buffer_size = 16M
#通信緩存區(qū)最大長(zhǎng)度,決定你sql語(yǔ)句中字符串最大長(zhǎng)度
max_allowed_packet = 1M
#排序緩存區(qū),決定你orderby的速度
sort_buffer_size = 512K
#通信緩存區(qū)大小,查詢時(shí)默認(rèn)該值為通信緩存區(qū)大小,若不夠會(huì)自動(dòng)增加直到達(dá)到max_allowed_packe
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)