mysql完整备份时过滤掉某些库的方法

数据库 发布日期:2024/9/22 浏览次数:1

正在浏览:mysql完整备份时过滤掉某些库的方法

mysql进行完整备份时使用--all-database参数

比如:

#mysqldump -u root -h localhost -p --all-database > /root/all.sql

数据导入的时候,可以先登陆mysql数据库中,使用source /root/all.sql进行导入。

问题:

想要在mysqldump备份数据库的时候,过滤掉某些库。

这种情况mysqldump备份的时候就不能使用--all-database了,而是使用--database。

如下:备份数据库的时候过滤掉information_schema、mysql 、test和jkhw_db库

[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"
Enter password:

+--------------------+
| Database |
+--------------------+
| information_schema |
| hqsb_db               |
| jkhw_db             |
| mysql                 |
| test                    |
| tech_db             |
| hqtime_o2o_db |
| hq_o2o_db        |
| hqtime_o2o_db_new |
+--------------------+
9 rows in set (0.00 sec)

操作方法:

[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|jkhw_db"
Enter password:
hqsb_db
tech_db
hqtime_o2o_db
hq_o2o_db
hqtime_o2o_db_new
[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|jkhw_db"|xargs
Enter password:
hqsb_db tech_db hqtime_o2o_db hq_o2o_db hqtime_o2o_db_new
[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|jkhw_db"|xargs mysqldump -uroot -p --databases > mysql_dump.sql
Enter password:

以上这篇mysql完整备份时过滤掉某些库的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。