Home > Database > Mysql Tutorial > 加速MySQL导入导出的方法_MySQL

加速MySQL导入导出的方法_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:34:35
Original
860 people have browsed it

bitsCN.com

加速MySQL导入导出的方法

 

MySQL导出的SQL语句在导入时有可能会非常慢,在处理百万级数据的时候,可能导入要花几小时。在导出时合理使用几个参数,可以大大加快导入的速度。

 

-e 使用多行INSERT语法,给出更紧缩并且更快的插入语句

--max_allowed_packet=XXX 客户端/服务器之间通信的缓存区的最大大小

--net_buffer_length=XXX TCP/IP和套接字通信缓冲区大小

 

max_allowed_packet和net_buffer_length不能比目标数据库的设定数值大,否则可能会出错。

 

首先确定目标数据库的参数值:

 

Sql代码  

mysql> show variables like 'max_allowed_packet';  

mysql> show variables like 'net_buffer_length';  

 

根据参数值写mysqldump命令:

 

Sql代码  

mysqldump -uroot -proot eric -e --max_allowed_packet=1048576 --net_buffer_length=16384 > eric.sql  

 

bitsCN.com
source:php.cn
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