Home > Database > Mysql Tutorial > body text

mysql高效导数据方法_MySQL

WBOY
Release: 2016-06-01 13:29:31
Original
921 people have browsed it

bitsCN.com

mysql高效导数据方法

 

模拟现网测试,需要搭建测试环境,导入上亿级的数据到数据库。对于到的问题做些简单记录。

 

数据:一个db,2000个表格,2000张表格数据,每条记录30个column,平均每张表格4.3w条记录,总共86388670条记录。

 

机器:linux 64bit 8G内存 4核IntelX3320@2.5GHz 

 

基本思路:

mysql -utest -pxxxx -s -e "source xxxx.sql"
Copy after login

将load语句放在xxxx.sql中

load语法:

load data  [low_priority] [local] infile 'file_name.txt' [replace | ignore]
Copy after login

如果串行导入数据,会很慢,考虑并行,但可能有冲突,解决办法:

load之前清空表

truncate table xxxx 或 delete from table xxxx;
Copy after login

 

 

或使用replace或ignore关键字。

 

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!