Home  >  Article  >  Database  >  How to import backup files in mysql

How to import backup files in mysql

藏色散人
藏色散人Original
2019-06-01 13:25:023430browse

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.

How to import backup files in mysql

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to install MySQL5.5Next article:How to install MySQL5.5