Home > Database > Mysql Tutorial > MySQL导入大容量SQL文件数据问题

MySQL导入大容量SQL文件数据问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:14:15
Original
1198 people have browsed it

MySQL导入大容量SQL文件数据问题,1.如果sql文件过大,会出现quot;MySQL server has gone awayquot;问题;2.如果sql文件数据有中

mysql在通过导入sql文件可能会出现下面二个问题:

1.如果sql文件过大,会出现"MySQL server has gone away"问题;

2.如果sql文件数据有中文,会出现乱码

解决问题:

问题1:出现MySQL server has gone away"问题,是因为mysql默认的"max_allowed_packet"变量值过小.

查看目前配置

show VARIABLES like '%max_allowed_packet%';

显示的结果为:

 

+--------------------+---------+

| Variable_name      | Value   |

+--------------------+---------+

| max_allowed_packet | 1048576 |

+--------------------+---------+

说明目前的配置是:1048576/1024/1024 = 1M

:

方法1: SET GLOBAL max_allowed_packet = 500*1024*1024;(经测试无效)

方法2: 直接修改配置文件,重启mysql

Windows修改my.ini文件,,在Linux中修改my.cnf文件.

C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.5\my.ini(安装mysql时的,指定的数据文件目录)

 

 

问题2:登录时指定字符集编码

mysql -uroot -P3308 -p123456  - -default-character-set=utf8  (-P是指指定端口号)

 

最后通过source命令 即可成功导入:

source  E:ydj\test.sql

 

linux

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template