Today, we used the source command to import data, but the ERROR 2006 (HY000) at line ***: MySQL server has gone away ERROR occurred, according to the prompt, it seems that the size is limited. I will refer to the specific process below.
Use the source function to import large files through the command line.
Import Database
Common source commands
Go to the mysql Database Console,
For example, mysql-u root-p
Mysql> use Database
Then run the source command. The following parameter is the script file (for example,. SQL used here)
Mysql> source d: chai. SQL
But it is okay to import a small file. The following error occurs when importing a large file:
1. ERROR 2006 (HY000) at line ***: MySQL server has gone away
2. Got a packet bigger than 'max _ allowed_packet 'bytes or ERROR 1153 (08S01) at line 616: Got a packet bigger than 'max _ allowed_packet' by tes
3. sqlyog:
There was an error while executing a query.
The query and the error message has been logged:
C: UsersliangAppDataRoamingSQLyogsqlyog. err.
Please click on "Open Error File..." to open the error file.
The above problems are generally caused by the parameter configuration of my. ini or my. cnf.
The specific configuration method is as follows:
Note: add the following configuration under [mysqld:
The max_allowed_packet = 768 M parameter size is set by myself. I imported a file of M, and I started to use 64 M. Then I changed it to M.
After the configuration is modified:
Restart mysql
Net stop mysql disabled
Net start mysql startup
Go to mysql to check whether the operation is successful
Show variables like '% max_allowed_packet % ';
Shown as follows:
Max_allowed_packet | 805306368 indicates that the modification is successful.
Re-import. Haha import successful!
Some may encounter other problems.
An ERROR at line: Unknown command ''' may occur in the database character set. You only need to add the following command at the end to solve the problem.
-- Default-character-set = utf8
That is
Mysql-u username-p Password Database Name <SQL file path -- default-character-set = utf8