程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> #2006-MySQLserverhasgoneaway

#2006-MySQLserverhasgoneaway

編輯:MySQL綜合教程

#2006-MySQLserverhasgoneaway


#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


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved