數據遷移、恢復,就要用到備份了。使用mysqldump導出來的基本都是sql數據句,可以直接使用mysql命令還原數據。
1、恢復到指定數據庫
mysql?-hhostname?-uusername?-ppassword?databasename?<p><strong>2、還原壓縮的MySQL數據備份文件</strong></p><pre class="brush:php;toolbar:false">gunzip?<p><strong>3、直接將備份導入到新的數據庫</strong></p><pre class="brush:php;toolbar:false">mysqldump?-uusername?-ppassword?databasename?|?mysql?-host=192.168.1.101?-C?databasename
4、使用source導入sql文件
mysql?>?use?cmdb mysql?>?source?/data/cmdb_backup.sql
總結
這些簡單的命令基本都是再遷移的時候使用的,如果是線上的數據庫,還要考慮到鎖表、binlog等,一步步來。
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END