Mysql may encounter the following two problems when importing an SQL file: 1. If the SQL file is too large, the "MySQL server has gone away" problem may occur;
2. if the SQL file data contains Chinese characters, the following error occurs: www.2cto.com. Problem 1: the MySQL server has gone away problem occurs because the default mysql "max_allowed_packet" variable value is too small. view current configuration
Show VARIABLES like '% max_allowed_packet % ';
The displayed result is: + ------------------ + --------- + | Variable_name | Value | + -------------------- + --------- + | max_allowed_packet | 1048576 | + ---------------------- + --------- +
The current configuration is: 1048576/1024/1024 = 1 M to modify the max_allowed_packet value:
Method 1: set global max_allowed_packet = 500*1024*1024; (tested)
Method 2: directly modify the configuration file and restart mysql www.2cto.com to modify my. INI file, modify my. cnf file. c: \ Documents ents and Settings \ All Users \ Application Data \ MySQL Server 5.5 \ my. ini (specified data file directory when mysql is installed)
After restarting mysql, check the modified max_allowed_packet value.
Question 2: When logging on, specify the character set encoding mysql-uroot-P3308-p123456--default-character-set = utf8 (-P refers to the specified port number) and then run the source command to import the data: source E: ydj \ test. SQL
Author: LoveJavaYDJ