Get the App
SLTechnology News&Howtos  ›  Database  › 

Using mysqldump tool to realize backup mysql command method

Shulou Source: shulou.com Published: 2022-06-01 18:26:45 09月18日 Update

The following to understand the use of mysqldump tools to achieve backup mysql command method, I believe you will benefit a lot after reading, the text in the essence is not much, hope to use mysqldump tools to achieve backup mysql command method this short content is what you want.

Mysqldump common backup options, methods of backing up only data or structures

Common options:

-- all-databases,-A: back up all databases

-- databases,-B: used to back up multiple databases. If this option is not available, mysqldump takes the first name parameter as the database name, followed by the table name. With this option, mysqldum treats each name as the database name.

-- force,-f: continue the backup even if an sql error is found

-- host=host_name,-h host_name: backup hostname. Default is localhost.

-- no-data,-d: only table structures are exported

-- password [= password],-p [password]: password

-- port=port_num,-P port_num: Port number when making a TCP/IP connection

-- quick,-Q: fast export

-- tables: overrides the-- databases or-B option, followed by parameters that are treated as table names

-- user=user_name,-u user_name: user name

-- xml,-X: export to xml file

1. Back up the data and structure of all databases

Mysqldump-uroot-p123456-A > F:\ all.sql

two。 Back up the structure of all databases (plus-d parameter)

Mysqldump-uroot-p123456-A-d > F:\ all_struct.sql

3. Back up the data of all databases (plus-t parameter)

Mysqldump-uroot-p123456-A-t > F:\ all_data.sql

4. Back 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. Back up data from a single database

Mysqldump-uroot-p123456 mydb-t > F:\ mydb.sql

7. Back up the data and structure of multiple tables (the separate backup method of data and structure is the same as above)

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 use mydb

Mysql > source f:\ mydb.sql

(2) mysql-uroot-p123456 mydb use mydb

Mysql > source f:\ multables.sql

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

(2) system command line: mysql-uroot-p123456

Tags: Data database file backup statement output command information parameter state multiple structure character method field single log comment system guarantee Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology MariaDB Linux macOS