問(wèn)題描述
當(dāng)我嘗試獲取大型 SQL 文件(大型 INSERT
查詢)時(shí)出現(xiàn)此錯(cuò)誤.
I get this error when I try to source a large SQL file (a big INSERT
query).
mysql> source file.sql
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2
Current database: *** NONE ***
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 3
Current database: *** NONE ***
表中的任何內(nèi)容都沒(méi)有更新.我試過(guò)刪除和取消刪除表/數(shù)據(jù)庫(kù),以及重新啟動(dòng) MySQL.這些都不能解決問(wèn)題.
Nothing in the table is updated. I've tried deleting and undeleting the table/database, as well as restarting MySQL. None of these things resolve the problem.
這是我的最大數(shù)據(jù)包大小:
Here is my max-packet size:
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
這里是文件大小:
$ ls -s file.sql
79512 file.sql
當(dāng)我嘗試另一種方法時(shí)...
When I try the other method...
$ ./mysql -u root -p my_db < file.sql
Enter password:
ERROR 2006 (HY000) at line 1: MySQL server has gone away
推薦答案
max_allowed_packet=64M
將此行添加到 my.cnf
文件中解決了我的問(wèn)題.
Adding this line into my.cnf
file solves my problem.
當(dāng)列有很大的值時(shí)這很有用,這會(huì)導(dǎo)致問(wèn)題,你可以找到解釋 此處.
This is useful when the columns have large values, which cause the issues, you can find the explanation here.
在 Windows 上,此文件位于:C:\ProgramData\MySQL\MySQL Server5.6"
On Windows this file is located at: "C:\ProgramData\MySQL\MySQL Server 5.6"
在 Linux (Ubuntu) 上:/etc/mysql
On Linux (Ubuntu): /etc/mysql
這篇關(guān)于ERROR 2006 (HY000): MySQL 服務(wù)器已經(jīng)消失的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!