Mysqldump Common Commands

Source: Internet
Author: User
Tags sql error mysql command line

Mysqldump Common
Mysqldump-u root-p--databases Database 1 database 2 > Xxx.sql


Restore: System command line: mysql-uroot-p123456 <f:\all.sql


Common options:
--all-databases,-A: Backing Up all databases
--databases,-B: For backing up multiple databases, if there is no option, Mysqldump takes the first name parameter as the database name, followed by the table name. With this option, Mysqldum takes each name as the database name.

--force,-F: Continue backup even if a SQL error is found
--host=host_name,-H host_name: Backup host name, localhost by default
--no-data,-D: Export table structure only
--password[=password],-p[password]: password
--port=port_num,-P Port_num: Port number when making TCP/IP connections
--quick,-Q: Quick Export
--tables: Overwrite--databases or-b option, followed by parameter is considered as table name
--user=user_name,-u user_name: User name
--xml,-X: Export as XML file

1. Back up the data and structure of all databases

Mysqldump-uroot-p123456-a >f:\all.sql

2. Backing up the structure of all databases (plus-d parameter)

Mysqldump-uroot-p123456-a-d>f:\all_struct.sql

3. Backing up data from all databases (plus-t parameters)

Mysqldump-uroot-p123456-a-t>f:\all_data.sql

4. Backing up the data and structure of a single database (, database name MyDB)

mysqldump-uroot-p123456 Mydb>f:\mydb.sql

5. Backing up the structure of a single database

mysqldump-uroot-p123456 Mydb-d>f:\mydb.sql

6. Backing up data from a single database

mysqldump-uroot-p123456 Mydb-t>f:\mydb.sql

7. Backup multiple tables of data and structure (data, the structure of a separate backup method and the same)

mysqldump-uroot-p123456 mydb T1 T2>f:\multables.sql

8. Back up multiple databases at a time

mysqldump-uroot-p123456--databases db1 Db2>f:\muldbs.sql

Restore partial (1) MySQL command line source method and (2) system command line method

1. Restore all databases:

(1) MySQL command line: Mysql>source f:\all.sql

(2) System command line: mysql-uroot-p123456 <f:\all.sql

2. Restore a single database (Specify a database)

(1) Mysql>use MyDB

Mysql>source F:\mydb.sql

(2) mysql-uroot-p123456 mydb <f:\mydb.sql

3. Restore multiple tables for a single database (Specify a database)

(1) Mysql>use MyDB

Mysql>source F:\multables.sql

(2) mysql-uroot-p123456 Mydb<f:\multables.sql

4. Restore multiple databases (a backup file with multiple databases, no database required at this time)

(1) MySQL command line: Mysql>source f:\muldbs.sql

(2) System command line: Mysql-uroot-p123456<f:\muldbs.sql

Mysqldump Common Commands

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.