Home >Database >Mysql Tutorial >How to import backup files in mysql
Data migration and recovery require backup. The data exported using mysqldump are basically SQL data sentences, and the data can be restored directly using the mysql command.
1. Restore to the specified database
mysql -hhostname -uusername -ppassword databasename < backupfile.sql
2. Restore the compressed MySQL data backup file
gunzip < backupfile.sql.gz | mysql -uusername -ppassword databasename
3. Directly import the backup into the new database
mysqldump -uusername -ppassword databasename | mysql -host=192.168.1.101 -C databasename
4. Use source to import the sql file
mysql > use cmdb mysql > source /data/cmdb_backup.sql
Summary
These simple commands are basically used when re-migrating. If it is an online database, you must also consider the lock table, binlog, etc., step by step.
The above is the detailed content of How to import backup files in mysql. For more information, please follow other related articles on the PHP Chinese website!