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

时间:2021-08-03  来源:mysql教程  阅读:

比如:

#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完整备份时过滤掉某些库的方法】mysql完整备份时过滤掉某些库的方法

http://m.bbyears.com/shujuku/133704.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新