MySQL imports large SQL file data. 1. If the SQL file is too large, quot; MySQLserverhasgoneawayquot; may occur. 2. If the SQL file data is in progress.
MySQL imports large-capacity SQL file data. 1. If the SQL file is too large, the following error occurs: quot; MySQL server has gone awayquot; 2. If the SQL file data is in progress.
Mysql may encounter the following two problems when importing SQL files:
1.IfSQLThe file is too large.,Will appear"MySQL server has gone away"Problem;
2.IfSQLFile data has Chinese Characters,Garbled
Solution:
Question 1:AppearsMySQL server has gone away"Problem,BecauseMysqlDefault"Max_allowed_packet"Variable value too small.
View current configuration
Show VARIABLES like '% max_allowed_packet % ';
The result is as follows:
+ -------------------- + --------- +
| Variable_name | Value |
+ -------------------- + --------- +
| Max_allowed_packet| 1048576 |
+ -------------------- + --------- +
The current configuration is as follows:1048576/1024/1024 = 1 M
:
Method1: set global max_allowed_packet = 500*1024*1024 ;(Tested invalid)
Method2:Directly modify the configuration file,RestartMysql
WindowsMediumModifyMy. iniFile, in LInuxModifyingMy. cnfFile.
C: \ Documents ents and Settings \ All Users \ Application Data \ MySQL Server 5.5 \ my. ini (InstallMysqlTime,Specified data file directory)
Question 2:Specify character set encoding when logging on
Mysql-uroot-P3308-p123456--default-character-set = utf8 (-PIndicates the specified port number.)
FinallySourceCommand to import successfully:
Source E: ydj \ test. SQL