Home > Database > Mysql Tutorial > body text

How to import backup files in mysql

藏色散人
Release: 2019-06-01 13:25:02
Original
3377 people have browsed it

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
Copy after login

2. Restore the compressed MySQL data backup file

gunzip < backupfile.sql.gz | mysql -uusername -ppassword databasename
Copy after login

3. Directly import the backup into the new database

mysqldump -uusername -ppassword databasename | mysql -host=192.168.1.101 -C databasename
Copy after login

4. Use source to import the sql file

mysql > use cmdb
mysql > source /data/cmdb_backup.sql
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!