MySQL how to back up and import a database

Source: Internet
Author: User
Tags db2 import database mysql command line


This article is mainly to share with you how MySQL database backup and import, hope to help everyone.

Back up all databases
The system command line executes:mysqldump -uusername -ppassword --all-databases > all.sql

Backing up a single database
The system command line executes: mysqldump -uusername -ppassword --databases db1 db2 > db.sql
Export DB1 and DB2 to a db.sql file.

Import Database
1. System command line execution: mysql -uusername -ppassword db1 < db1.sql
In this case, the DB1 database must be built in advance.
2. Or under MySQL command line execution: source db1.sql
In this way, you do not need to create the database beforehand, and the database is created automatically.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.