Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL uses mysqldump backup and mysql command to restore

Shulou Source: shulou.com Published: 2022-06-01 18:35:11 09月29日 Update

The following mainly brings you MySQL using mysqldump backup and mysql command restore, I hope these contents can bring you practical use, this is also the main purpose of my editing MySQL using mysqldump backup and mysql command to restore this article. All right, don't talk too much nonsense, let's just read the following.

First, use mysqldump to back up 1. Backup database basic syntax mysqldump-u user-h host-p password dbname [tbname, [tbname...]] > filename.sql

Example:

C:\ > mysqldump-u root-p booksdb > c:\ backup\ booksdb_20110101.sqlEnter password: * * 2. Use mysqldump to back up a table in the database mysqldump-u user-p123-d booksDB books > c:\ backup\ books_20110101.sql

-u user specifies the user name

-p123 specify password

-d booksDB only backs up the table structure and does not back up data. Do not specify-d, that is, backup table structure also backup table data

-- skip-extended-insert exports multiple insert statements

3. Backing up multiple databases using mysqldump

If you back up multiple databases, you need to use the-- databases parameter in the following format

Mysqldump-u user-h host-p-- all-- databases > filename.sql

You do not need to specify a database name when using the-- all--databases parameter

For example, to back up all the databases in the CVM, enter the following statement:

Mysqldump-u root-p-- all--databases > c:\ backup\ alldbinMySQL.sql II, restore using the mysql command

For files that have been backed up that contain create and insert statements, you can import them into the database using the mysql command

Mysql-u user-p [dbname]

Tags: Backup data database command file statement content following text parameter multiple server structure syntax service name multiple actual password tool nonsense Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Shulou Tech Info Docker Apple