1. 程式人生 > 實用技巧 >資料庫備份與還原

資料庫備份與還原

mysql資料庫備份的方式

  • 使用命令列匯出 mysqldump 命令列使用

語法:

  備份:mysqldump -u使用者名稱 -p密碼 資料庫名 > 儲存的路徑

  還原:

    登入資料庫

    建立資料庫

    使用資料庫

    執行檔案,source 檔案路徑

	# mysqldump -h 主機 -u 使用者名稱 -p 密碼 資料庫 表名 > 物理磁碟位置/檔名
	mysqldump -hlocalhost -uroot -p123456 school student > D:/a.sql
	 
	# mysqldump -h 主機 -u 使用者名稱 -p 密碼 資料庫 表1 表2 表3 > 物理磁碟位置/檔名
	mysqldump -hlocalhost -uroot -p123456 school student > D:/b.sql
	 
	# mysqldump -h 主機 -u 使用者名稱 -p 密碼 資料庫 > 物理磁碟位置/檔名
	mysqldump -hlocalhost -uroot -p123456 school student > D:/c.sql
	 
	# 匯入
	# 登入的情況下,切換到指定的資料庫
	# source 備份檔案
	source d:/a.sql

圖形化操作很簡單,不同的客戶端大同小異