《Mysql入門mysqldump備份數(shù)據(jù)庫時排除某些庫的實例》要點:
本文介紹了Mysql入門mysqldump備份數(shù)據(jù)庫時排除某些庫的實例,希望對您有用。如果有疑問,可以聯(lián)系我們。
說明:MYSQL應(yīng)用
使用mysqldump Call-databases會導(dǎo)出所有庫.但如果做主從,從主庫dump出數(shù)據(jù)時,我們是不需要也不想要information_schema 和 mysql 庫的.數(shù)據(jù)庫少的情況下還可以通過/usr/local/mysql/bin/mysqldump -uroot -p --databases db1 db2 > db1db2.sql 這樣再導(dǎo)出,但如果數(shù)據(jù)多,這樣指定就很麻煩了.MYSQL應(yīng)用
mysql是支持 ignore-table 的,但是沒有ignore-database,所以要導(dǎo)出除 information_schema和mysql庫的其它所有庫,難道就只能一個個指定database嗎?MYSQL應(yīng)用
解決:MYSQL應(yīng)用
# mysql -e "show databases;" -uroot -p| grep -Ev "Database|information_schema|mysql|test" | xargs mysqldump -uroot -p --databases > mysql_dump.sqlMYSQL應(yīng)用
附錄:MYSQL應(yīng)用
附錄1:mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user ‘root'@'localhost' for table ‘cond_instances' when using LOCK TABLESMYSQL應(yīng)用
在mysql5.5中增加了performance_schema,當(dāng)我們進(jìn)行mysqldump的時候,會報如下錯誤信息:MYSQL應(yīng)用
mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user ‘root'@'localhost' for table ‘cond_instances' when using LOCK TABLESMYSQL應(yīng)用
我們可以在mysqldump中加上參數(shù) Cskip-lock-tables,如MYSQL應(yīng)用
# mysqldump? -uroot? -p?? --skip-lock-tables? performance_schema > performance_schema.sql 或者過濾掉performance_schema這個庫MYSQL應(yīng)用
# mysql -e "show databases;" -uroot -p| grep -Ev "Database|information_schema|mysql|test|performance_schema" | xargs mysqldump -uroot -p --databases > mysql_dump.sqlMYSQL應(yīng)用
以上這篇mysqldump備份數(shù)據(jù)庫時排除某些庫的實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持維易PHP.MYSQL應(yīng)用
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/1652.html