[英]how to backup some specific table from db and save the .sql to some location in my computer , using php code?
我需要對數據庫中某些選定表進行備份。我的php頁面中有一個表單,當單擊表單上的“提交”按鈕時,選定表的備份將以.sql或.sql zip文件的形式存儲到我的計算機中。
(例如:如果db1是我的數據庫名稱,table1,table2,table3是表,則單擊表單中的Submit按鈕僅備份tabl1,table2並將其另存為我的計算機中的.sql或.sqlzip文件)。
如果有人知道解決方案,請在此處發布。
如果要從mydb轉儲表t1,t2和t3
mysqldump -uYouruser -pYourPassword YourDBName Table1 Table2 Table3 > /PathWhereToStoreBackup/mydb_tables.sql
如果mydb中有大量表,並且想轉儲t1,t2和t3以外的所有內容,請執行以下操作:
DBTODUMP=mydb
TBLIST=`mysql -u... -p... -AN -e"select group_concat(table_name separator ' ') from information_schema.tables where table_schema='${DBTODUMP}' and table_name not in ('t1','t2','t3')"`
mysqldump -u... -p... ${DBTODUMP} ${TBLIST} > mydb_tables.sql
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.