2009-12-30 34 views
35

Im sử dụng Wampserver phiên bản 2.0. Khi tôi cố gắng để nhập một tập tin sql, hoặc thông qua MySQL Query Browser hoặc PHPMyAdmin, tôi nhận được lỗi sau.# 2006 MySQL Server đã ra đi lỗi trong WAMP

Error 2006: MySQL Server has gone away. 

Kích thước của tệp là 54,528 KB.

Trong C: \ wamp \ bin \ mysql \ mysql5.1.30 \ my.ini, tôi đặt max_allowed_packet thành 100M trong [mysqldump] và [wampmysqld]. Tôi không thể tìm biến wait_timeout trong my.ini. Bất kỳ cách nào để khắc phục vấn đề này? Để bạn tham khảo, tôi đã đưa ra bên dưới nội dung của tệp 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 
+3

thử khởi động lại máy chủ mysql – Krunal

+1

Cảm ơn Krunal đã sửa nó! :) – john

+0

bản sao có thể có của [lỗi MySQL 2006: máy chủ mysql đã biến mất] (http://stackoverflow.com/questions/7942154/mysql-error-2006-mysql-server-has-gone-away) –

Trả lời

62

Tôi đang sử dụng XAMPP trên Windows và có cùng sự cố. Tôi nghĩ đó là biến thời gian chờ nhưng nó là max_allowed_packet.

này đã cố định nó:

# 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 

tập tin cấu hình này tọa lạc tại «XAMPP cài đặt thư mục, đây làC:\XAMPPtheo mặc định»\mysql\bin\my.ini.

+3

Câu trả lời này đã giúp tôi cũng vậy nhưng đối với những người rất mới để phát triển quá trình như tôi, tôi sẽ thêm rằng tập tin này được đặt tên là "my.ini" và được tìm kiếm ở vị trí này "C: \ xampp \ mysql \ bin \ my.ini" - Bên cạnh đó , Tôi đề nghị bạn thiết lập max_allowed_packet = 10M vì nếu bạn sử dụng drupal 7 như tôi một số bảng có thể có một bộ nhớ cache kích thước lớn. – wocmultimedia

+0

Vâng, điều đó xảy ra khi các hàng đơn lẻ trở nên quá lớn. +1 –

+3

Vâng, làm cho key_buffer và max_allowed_packet 16M thường giải quyết vấn đề này. –

5

Tôi đang sử dụng Xampp 1.7.7 trên Windows 7 và cũng gặp sự cố tương tự. dưới đây là những gì cố định nó:

  • Tăng giá trị mysql.connect_timeout:
    ; Thời gian tối đa (tính bằng giây) cho thời gian chờ kết nối. -1 có nghĩa là không có giới hạn
    ; http://php.net/mysql.connect-timeout
    mysql.connect_timeout = 10; nó là 3 theo mặc định

  • Đã thử những gì tôi đã làm trước đó và gặp phải sự cố khác về 'max_allowed_packet'.

  • Đi tới mysql \ bin \ my.ini và tìm thiết lập max_allowed_packet = 1M, sau đó thay đổi thành 10M: max_allowed_packet = 10M; Mặc định là 1M

Hy vọng điều này có thể hữu ích.

Đức Documentation

2

phpMyAdmin:

1.16 Tôi không thể tải lên các tập tin dump lớn (bộ nhớ, HTTP hoặc thời gian chờ vấn đề).

Bắt đầu với phiên bản 2.7.0, công cụ nhập đã được viết lại và những sự cố này sẽ không xảy ra. Nếu có thể, hãy nâng cấp phpMyAdmin của bạn lên phiên bản mới nhất để tận dụng các tính năng nhập mới.

Những điều đầu tiên cần kiểm tra (hoặc yêu cầu nhà cung cấp máy chủ của bạn kiểm tra) là các giá trị của upload_max_filesize, memory_limit và post_max_size trong tệp cấu hình php.ini. Tất cả ba cài đặt này giới hạn kích thước tối đa của dữ liệu có thể được gửi và xử lý bởi PHP. Một người dùng cũng cho biết rằng post_max_size và memory_limit cần phải lớn hơn upload_max_filesize.

Có tồn tại một số cách giải quyết nếu tải lên của bạn quá lớn hoặc nhà cung cấp hosting của bạn là không muốn thay đổi các thiết lập:

Nhìn vào $ cfg [ 'UploadDir'] tính năng. Điều này cho phép người dùng tải tệp lên máy chủ thông qua scp, ftp hoặc phương thức truyền tệp yêu thích của bạn. PhpMyAdmin sau đó có thể nhập các tệp từ thư mục tạm thời. Thông tin thêm có sẵn trong phần Cấu hình của tài liệu này.

Sử dụng tiện ích (chẳng hạn như BigDump) để chia nhỏ các tệp trước khi tải lên. Chúng tôi không thể hỗ trợ ứng dụng này hoặc bất kỳ ứng dụng của bên thứ ba nào, nhưng nhận thức được người dùng có thành công với ứng dụng đó.

Nếu bạn có quyền truy cập shell (dòng lệnh), hãy sử dụng MySQL để nhập trực tiếp các tệp. Bạn có thể làm điều này bằng cách ban hành lệnh "source" từ bên trong MySQL: source filename.sql.

1

ĐỐI VỚI CÁC NHÀ PHÁT TRIỂN SỬ DỤNG Mac OSX, bạn cần thay đổi max_allowed_packet từ 1M thành 10M trong tệp "my.cnf".

max_allowed_packet = 10M 

Bạn có thể sẽ tìm tập tin "my.cnf" trong một trong các địa điểm sau:

  1. /etc/my.cnf (LOCATION khả năng nhất cho Mavericks NGƯỜI SỬ DỤNG)
  2. /etc/mysql/my.cnf
  3. SYSCONFDIR/my.cnf
  4. $ MYSQL_HOME/my.cnf
  5. mặc-phụ-file (tập tin chỉ định với --defaults-phụ-file = con đường, nếu có)
  6. ~/.my.cnf
1

Các bước để giải pháp MySQL lỗi 2006:

  1. Chỉnh sửa “my.ini” tập tin tìm thấy tại “: \ xampp \ mysql \ bin \”.
  2. Trong tệp my.ini, hãy chỉnh sửa "max_allowed_packet" bằng cách tăng giá trị.
    • Giá trị mặc định XAMPP là 1M. Tôi đã cập nhật nó lên 10 triệu.
  3. Lưu tệp my.ini.
  4. Khởi động lại máy chủ MySQL và Apache của bạn trong XAMPP.
4

này có thể là do max_allowed_packet

Thay đổi trong file my.ini/my.cnf. Bao gồm các dòng dưới [mysqld] trong tập tin của bạn

max_allowed_packet=500M 

nay khởi động lại MySQL service một khi bạn đã làm xong. Bạn có thể thấy giá trị của nó curent trong mysql như thế này:

SHOW VARIABLES LIKE 'max_allowed_packet' 

Bạn có thể đọc về nó ở đây http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html

0

tôi nhận thấy lỗi này khi cập nhật phiên bản Magento từ x đến y. Nhìn vào các bản ghi tôi thấy có một vấn đề trong một bảng.

[ERROR] Chỉ mục UNQ_DH_CORE_URL_REWRITE_REQUEST_PATH_STORE_ID của databaseabc/core_url_rewrite có 2 cột duy nhất bên trong InnoDB, nhưng MySQL đang yêu cầu thống kê cho 3 cột. Bạn đã trộn lẫn các tệp .frm từ các bản cài đặt khác nhau chưa? Xem http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html

Sửa bảng này đã khắc phục sự cố. Trong trường hợp của tôi, tôi có thể cắt bớt bảng vì đó là một chỉ mục có thể được tạo lại.

0

Nếu tăng kích thước bộ nhớ bộ nhớ không hoạt động cho bạn, hãy kiểm tra mã của bạn cho một vòng lặp vô hạn.

Đó là những gì tôi có trong mã đã hết bộ nhớ của mình cho dù tôi đã tăng nó lên bao nhiêu. Theo dõi ngăn xếp cho các đầu mối tốt, đảm bảo debugging is turned on, ít nhất là cục bộ!

Các vấn đề liên quan