mysql怎么導入備份文件

數據遷移、恢復,就要用到備份了。使用mysqldump導出來的基本都是sql數據句,可以直接使用mysql命令還原數據。

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?&gt;?use?cmdb mysql?&gt;?source?/data/cmdb_backup.sql

總結

這些簡單的命令基本都是再遷移的時候使用的,如果是線上的數據庫,還要考慮到鎖表、binlog等,一步步來。

? 版權聲明
THE END
喜歡就支持一下吧
點贊5 分享