Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of backup and recovery parameters of Mysql Database

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Backup:

1. Back up the data and structure of all databases

Mysqldump-uroot-p123456-A > / tmp/all.sql

-A: back up all databases =-- all-databases

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

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

-A: backup all databases =-- all-databases-- no-data,-d: only export table structure

3. Back up the data and structure of a single database (database name mydb)

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

4. Back up the table structure of a single database (without backing up the actual data) very quickly

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

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

5. Back up the data and structure of multiple tables (data, the separate backup method of the structure is the same as above) (back up multiple tables at a time)

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

6. Back up multiple databases at a time

Mysqldump-uroot-p123456-- databases db1 db2 > f:\ muldbs.sql

Mysqldump-uroot-pjsb-B bk0 bk1 > bk01.sql (same result as above)

-- 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. Use this option

Instructions for command operation:

1. Export structure does not export data

Mysqldump-d database name-uroot-p > xxx.sql

two。 Export data does not export structure

Mysqldump-t database name-uroot-p > xxx.sql

3. Export data and table structure

Mysqldump database name-uroot-p > xxx.sql

4. Export the structure of a specific table

Mysqldump-uroot-p-B database name-- table table name > xxx.sql

Restore-restore:

Restore all databases 2 method: (backup set of database is required)

(1) mysql command line source method

(1) mysql command line: source backup set path / backup set name .SQL

(2) system command line method

(2) system command line: mysql-u account-p password < backup set path / backup set name .sql

1. Restore a single database (you need to specify a backup set for the database)

Mysql command line source method:

Mysql-uroot-p123456

Cd enters the directory where you store the recovery script (or backup set)

Use test

Source f:\ backup name .sql

System command line method: as follows (recommended)

Mysql-uroot-p123456 mydb < f:\ mydb.sql

two。 Restore multiple tables of a single database (requires backup sets of multiple tables of a single database)

Mysql command line source method:

Use mydb

Cd enters the directory where you store the recovery script (or backup set)

Source backup set path / backup set name .SQL

System command line method: as follows (recommended)

Mysql-uroot-p123456 mydb < f:\ tables.sql

3. Restore multiple databases, (there are backups of multiple databases in a backup file, and there is no need to specify a database at this time)

Mysql command line:

Source f:\ dbs1.sql

System command line: (recommended)

Mysql-uroot-p123456 < backup set path / backup set name .sql

Mysql-uroot-p123456 < bk01.sql

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report