[root@localhost tmp]# seq 1 10000000 > /tmp/bigfile 先生成一个数据表
[root@localhost tmp]# ll -h /tmp/bigfile
-rw-r--r-- 1 root root 109M 01-30 16:36 /tmp/bigfile 生成的文件大小
mysql> create database aa; 创建一个数据库
mysql> use aa;
mysql> create table user (a int);
mysql> load data infile '/tmp/bigfile' into table user; 把/tmp/bigfile 数据导入进来
Query OK, 10000000 rows affected (11.20 sec)
Records: 10000000 Deleted: 0 Skipped: 0 Warnings: 0
mydumper 进行数据的备份
[root@localhost tmp]# time mysqldump -u root aa > /tmp/mysql.bak
real 0m17.885s
user 0m2.980s
sys 0m2.699s
然后把aa的数据库删除,下面就是还原数据内容
myload
[root@localhost tmp]# time mysql -u root aa < /tmp/mysql.bak
real 0m28.903s
user 0m3.164s
sys 0m1.301s
mysqldump用第三方软件
[root@localhost ~]# yum install gcc gcc-c++ glib2-devel mysql-devel zlib-devel pcre-devel -y 安装mysqldump准备的工作环境
[root@localhost ~]# cd /tmp
[root@localhost tmp]# rpm -ivh cmake-2.6.4-7.el5.i386.rpm
[root@localhost tmp]# tar fvxz mydumper-0.2.3.tar.gz
[root@localhost tmp]# cd /tmp/mydumper-0.2.3
[root@localhost mydumper-0.2.3]# cmake .
[root@localhost mydumper-0.2.3]# make && make install
[root@localhost ~]# mkdir -pv /tmp/sqlbak 建立备份的目录
mkdir: 已创建目录 “/tmp/sqlbak”
数据的备份
[root@localhost tmp]# time mydumper -B aa -u root -o /tmp/sqlbak
real 0m13.726s
user 0m3.181s
sys 0m1.291s
数据的还原
[root@localhost tmp]# time myloader -u root -d /tmp/sqlbak -B aa
real 0m30.528s
user 0m2.903s
sys 0m1.604s