MySQL——CentOS安装mydumper及其使用

安装前的准备:

mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar
链接:https://pan.baidu.com/s/1gYTzTSys9Ri3NyGjvNpDUw
提取码:vpoq

mydumper-0.9.1.tar.gz
链接:https://pan.baidu.com/s/1Ew-ebRUJwXpoYRjByPKF5Q
提取码:vn8d


环境搭建:

1.上传软件包
mydumper-0.9.1.tar.gz和mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar

2.安装依赖包

先解压已上传的软件包

[root@MySQL ~]# ll
total 556048
-rw-------. 1 root root      1537 Jul  2 19:07 anaconda-ks.cfg
-rw-r--r--. 1 root root     44463 Jul 16 16:14 mydumper-0.9.1.tar.gz
-rw-r--r--. 1 root root 569344000 Jul  3 11:03 mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar
[root@MySQL ~]# tar xvf mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar 
[root@MySQL ~]# ll
/*该处只列举了需要用到的三个依赖包,其他的包省略了*/
total 1112056
-rw-------. 1 root root       1537 Jul  2 19:07 anaconda-ks.cfg
-rw-r--r--. 1 root root      44463 Jul 16 16:14 mydumper-0.9.1.tar.gz
-rw-r--r--. 1 root root  569344000 Jul  3 11:03 mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415    277608 Jul 14  2016 mysql-community-common-5.7.14-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415   3770552 Jul 14  2016 mysql-community-devel-5.7.14-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415   2235496 Jul 14  2016 mysql-community-libs-5.7.14-1.el7.x86_64.rpm

为了方便安装需要的三个依赖包,把其他的包删除掉,使用rm -i可选择删除不需要的包;
也可使用这条命令直接安装,yum -y mysql-community-devel-5.7.14-1.el7.x86_64.rpm mysql-community-devel-5.7.14-1.el7.x86_64.rpm mysql-community-libs-5.7.14-1.el7.x86_64.rpm
安装的时候会报错,请看下面的解决方法;

[root@MySQL ~]# rm -i *rpm
rm: remove regular file ‘mysql-community-client-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-common-5.7.14-1.el7.x86_64.rpm’? n
rm: remove regular file ‘mysql-community-devel-5.7.14-1.el7.x86_64.rpm’? n
rm: remove regular file ‘mysql-community-embedded-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-embedded-compat-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-embedded-devel-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-libs-5.7.14-1.el7.x86_64.rpm’? n
rm: remove regular file ‘mysql-community-libs-compat-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-minimal-debuginfo-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-server-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-server-minimal-5.7.14-1.el7.x86_64.rpm’? y
rm: remove regular file ‘mysql-community-test-5.7.14-1.el7.x86_64.rpm’? y
[root@MySQL ~]# yum -y install glib2-devel  zlib-devel pcre-devel gcc gcc-c++ cmake
[root@MySQL ~]# yum install -y *.rpm

yum install -y *.rpm,指的是安装该目录下所有的rpm包;
安装三个包的时候会出错,提示移除mariadb-libs,使用命令yum remove mariadb-libs;
使用扩展源,则不需要移除mariadb-libs,使用命令wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3.安装mydumper

[root@MySQL ~]# tar xf mydumper-0.9.1.tar.gz 
[root@MySQL ~]# ll
drwxr-xr-x. 4 root root       4096 Sep 10 04:06 mydumper-0.9.1
-rw-r--r--. 1 root root      44463 Jul 16 16:14 mydumper-0.9.1.tar.gz
[root@MySQL ~]# cd mydumper-0.9.1/
[root@MySQL mydumper-0.9.1]# camake.
[root@MySQL mydumper-0.9.1]# make
[root@MySQL mydumper-0.9.1]# make install

MySQL——CentOS安装mydumper及其使用_第1张图片
安装完成后生成两个二进制文件 mydumper 和 myloader 位于 /usr/local/bin 目录下。


mydumper的使用:

1.备份

[root@localhost ~]# mydumper -u root -p123 -t 4 -B school -o /backup/school

mydumper备份是以文件夹形式备份,如果是以源码安装的MySQL需要加套接字(-S /tmp/mysql.sock),如有不会请mydumper --help。
示例:mydumper -u root -p123 -t 4 -S /tmp/mysql.sock -B school -o /backup/school

2.恢复

如果数据库不存在,先创建数据库

mysql> create database booksDB;
[root@localhost ~]# myloader -u root -p123 -d /backup/school/ -o -B school

你可能感兴趣的:(MySQL,centos,linux,mysql)