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完整備份時過濾掉某些庫的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:- MySQL全面瓦解之查詢的過濾條件詳解
- MySQL單表查詢操作實例詳解【語法、約束、分組、聚合、過濾、排序等】
- MySQL中無過濾條件的count詳解
- Mysql數據庫實現多字段過濾的方法
- MySQL注入繞開過濾的技巧總結
- MYSQL必知必會讀書筆記第八章之使用通配符進行過濾
- MYSQL必知必會讀書筆記第七章之數據過濾
- MYSQL必知必會讀書筆記第六章之過濾數據
- MYSQL使用正則表達式過濾數據
- Python連接MySQL并使用fetchall()方法過濾特殊字符
- python實現mysql的單引號字符串過濾方法
- mysql 復制過濾重復如何解決
- mysql 如何動態修改復制過濾器