2010年2月3日 星期三

mysql在linux下指令備份還原

備份
-u:指帳號
-p:指密碼
將testDB(DB name)的testTable(table name)備份至test.txt(不含table內的資料
mysqldump -uroot -prootpwd --no-data testDB testTable > test.txt

將testDB(DB name)的testTable(table name)備份至test.txt(不含create table語法
mysqldump -uroot -prootpwd --no-create-info testDB testTable > test.txt

備testDB整個DB的資料
mysqldump -uroot -prootpwd testDB > test.txt

備testDB的testTable、testTable2、testTable3備份至test.txt
mysqldump -uroot -prootpwd testDB testTable testTable2 testTable3 > test.txt

還原
將test.txt的資料還原至 testDB(DB name)
mysql -uroot -prootpwd testDB < test.txt

參考資料:http://imysql.cn/mysql_backup_and_recover

沒有留言: