mysql完整備份時過濾掉某些庫的方法
mysql進行完整備份時使用--all-database參數(shù)
比如:
#mysqldump -u root -h localhost -p --all-database > /root/all.sql
數(shù)據(jù)導入的時候,可以先登陸mysql數(shù)據(jù)庫中,使用source /root/all.sql進行導入。
問題:
想要在mysqldump備份數(shù)據(jù)庫的時候,過濾掉某些庫。
這種情況mysqldump備份的時候就不能使用--all-database了,而是使用--database。
如下:備份數(shù)據(jù)庫的時候過濾掉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完整備份時過濾掉某些庫的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
wampserver下mysql導入數(shù)據(jù)庫的步驟
這篇文章主要介紹了wampserver下mysql導入數(shù)據(jù)庫的步驟,需要的朋友可以參考下2016-08-08
MySQL group by對單字分組序和多字段分組的方法講解
今天小編就為大家分享一篇關于MySQL group by對單字分組序和多字段分組的方法講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03

