Home > Database > Mysql Tutorial > MySQL导入慢的解决方法_MySQL

MySQL导入慢的解决方法_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:35:03
Original
1007 people have browsed it

bitsCN.com

MySQL导入慢的解决方法

 

MySQL导出的SQL语句在导入时有可能会非常非常慢,在导出时合理使用几个参数,可以大大加快导 入的速度.

 

导入注意点:

 

使用phpmyadmin或navicat之类的工具的导入功能还是会相当慢,可以直接使用mysql进行导入

 

导入命令如下: mysql> -uroot -psupidea 要导入到的数据库名

说明: mysql> -umysql用户名 -pmysql密码 要导入到的数据库名

这样导入将会非常快,之前数小时才能导入的sql现在几十秒就可以完成了。 

 

导出时候注意点:

-e  使用包括几个VALUES列表的多行INSERT语法; 

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

--net_buffer_length=XXX TCP/IP和套接字通信缓冲区大小,创建长度达net_buffer_length的行。 

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

首先确定目标库的参数值 

mysql>show variables like 'max_allowed_packet'; 

mysql>show variables like 'net_buffer_length'; 

根据参数值书写mysqldump命令,如: 

mysql>mysqldump -uroot -psupidea 要导入到的数据库名 goodclassification -e --max_allowed_packet=1048576 --net_buffer_length=16384 >要导入到的数据库名.net.sql

 

bitsCN.com

Related labels:
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template