#2006 MySQL服务器在Wamp中消失了

时间:2009-12-30 12:39:28

标签: mysql wamp mysql-error-2006

我正在使用Wampserver 2.0版。当我尝试通过MySQL查询浏览器或PHPMyAdmin导入sql文件时,我收到以下错误。

Error 2006: MySQL Server has gone away.

文件大小为54,528 KB。

在C:\ wamp \ bin \ mysql \ mysql5.1.30 \ my.ini中,我在[mysqldump]和[wampmysqld]中将max_allowed_pa​​cket设置为100M。我在my.ini中找不到wait_timeout变量。 有什么方法可以解决这个问题吗?供您参考,我在下面给出了my.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]
port        = 3306
socket      = /tmp/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 100M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
basedir=c:/wamp/bin/mysql/mysql5.1.30
log-error=c:/wamp/logs/mysql.log
datadir=c:/wamp/bin/mysql/mysql5.1.30/data

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# 
#skip-networking

# Disable Federated by default
skip-federated

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# binary logging format - mixed recommended
binlog_format=mixed

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id   = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Point the following paths to different dedicated disks
#tmpdir     = /tmp/     
#log-update     = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\mysql\data/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\mysql\data/
#innodb_log_arch_dir = C:\mysql\data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 100M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

[mysqld]
port=3306

8 个答案:

答案 0 :(得分:63)

我在Windows上使用XAMPP并遇到了同样的问题。 我认为这是超时变量,但它是max_allowed_packet

这修复了它:

# note the change was made at this section
[mysqld] 
port= 3306
socket= "/xampp/mysql/mysql.sock"
basedir="/xampp/mysql" 
tmpdir="/xampp/tmp" 
datadir="/xampp/mysql/data"
skip-locking
key_buffer = 16M
# it was 1M by default
max_allowed_packet = 2M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

此配置文件位于«XAMPP安装目录,默认情况下 C:\XAMPP » \mysql\bin\my.ini

答案 1 :(得分:5)

我在Windows 7上使用Xampp 1.7.7并且也遇到了同样的问题。 以下是修正它的原因:

  • 增加mysql.connect_timeout值:
    ;连接超时的最长时间(以秒为单位)。 -1表示没有限制
    ; http://php.net/mysql.connect-timeout
    mysql.connect_timeout = 10;它默认为3

  • 尝试过我之前做过的事情并且遇到了另一个关于&#39; max_allowed_pa​​cket&#39;

  • 的问题。
  • 转到mysql \ bin \ my.ini并找到设置max_allowed_pa​​cket = 1M,然后将其更改为10M: max_allowed_pa​​cket = 10M;默认情况下为1M

希望这可以提供帮助。

答案 2 :(得分:5)

这可能是因为max_allowed_packet

更改my.ini/my.cnf文件。在您的文件

中包含[mysqld]下的单行
max_allowed_packet=500M

现在完成后重新启动MySQL service。你可以在mysql中看到它的有用价值:

SHOW VARIABLES LIKE 'max_allowed_packet'

您可以在此处阅读http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html

答案 3 :(得分:2)

PhpMyAdmin文档:

1.16我无法上传大转储文件(内存,HTTP或超时问题)。

从2.7.0版开始,导入引擎已被重写,不应出现这些问题。如果可能,请将phpMyAdmin升级到最新版本,以利用新的导入功能。

要检查的第一件事(或要求主机提供商检查)是php.ini 配置文件中 upload_max_filesize,memory_limit和post_max_size的值。所有这三个设置都限制了PHP可以提交和处理的最大数据大小。一位用户还说post_max_size和memory_limit需要大于upload_max_filesize。

如果您的上传太大或您的托管服务提供商不愿意更改设置,则存在多种解决方法:

查看$ cfg ['UploadDir']功能。这允许用户通过scp,ftp或您喜欢的文件传输方法将文件上传到服务器。然后,PhpMyAdmin可以从临时目录导入文件。有关详细信息,请参阅本文档的“配置”部分。

在上传之前使用实用程序(如BigDump)拆分文件。我们不能支持这个或任何第三方应用程序,但是知道用户已经成功使用它。

如果您有shell(命令行)访问权限,请使用MySQL直接导入文件。您可以通过在MySQL中发出“source”命令来执行此操作:source filename.sql。

答案 4 :(得分:1)

对于使用Mac OSX的开发人员,您需要在“my.cnf”文件中将max_allowed_pa​​cket从1M更改为10M。

max_allowed_packet = 10M

您可能会在以下某个位置找到“my.cnf”文件:

  1. /etc/my.cnf(MAVERICKS用户最可爱的位置)
  2. /etc/mysql/my.cnf
  3. SYSCONFDIR / my.cnf中
  4. $ MYSQL_HOME / my.cnf中
  5. defaults-extra-file(使用--defaults-extra-file = path指定的文件,如果有的话)
  6. 〜/ .my.cnf

答案 5 :(得分:1)

MySQL错误2006解决方案的步骤:

  1. 编辑位于“:\ xampp \ mysql \ bin \”的“my.ini”文件。
  2. 在my.ini文件中,通过增加值来编辑“max_allowed_pa​​cket”。
    • XAMPP默认值为1M。我将其更新为10M。
  3. 保存my.ini文件。
  4. 在XAMPP中重新启动MySQL和Apache服务器。

答案 6 :(得分:0)

我在将Magento从版本x更新为y时发现了这个错误。看看日志,我看到桌子上有一个问题。

[错误]索引UNQ_DH_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID dataabc / core_url_rewrite在InnoDB中有2列唯一,但MySQL要求统计3列。您是否混合了来自不同安装的.frm文件?见http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html

修复此表修复了该问题。 在我的情况下,我可以截断表,因为它是一个可以再次生成的索引。

答案 7 :(得分:0)

如果增加内存大小答案不适合您,请检查代码是否无限循环。

这就是我在我的代码中所拥有的东西,无论我增加了什么,它都耗尽了我的记忆。堆栈跟踪提供了良好的线索,确保debugging is turned on,至少在本地!