Mysqldump Export Database Parameters detailed description

Source: Internet
Author: User
Tags create database

Mysqldump is a utility that MySQL uses to store databases. It primarily produces a SQL script that contains the commands necessary to recreate the database from scratch, create TABLE insert, and so on.

Let's look at the various examples of mysqldump exports in detail:

1 exporting the structure of a database

mysqldump-d dbname-uroot-p > Dbname.sql

2 exporting the structure of multiple databases

Mysqldump-d-B dbname1 dbname2-uroot-p > Dbname.sql

3 exporting data from a database (without structure)

Mysqldump-t dbname-uroot-p > Dbname.sql

4 Exporting data from multiple databases (with no structure)

Mysqldump-t-B dbname1 dbname2-uroot-p > Dbname.sql

5 Exporting the structure and data of a database

Mysqldump dbname-uroot-p > Dbname.sql

6 exporting the structure and data of multiple databases

Mysqldump-b dbname1 dbname2-uroot-p > Dbname.sql

7 exporting the structure of a table in a database

mysqldump-d dbname1 tablename-uroot-p > Tablename.sql

8 exporting the structure of multiple tables in a database

Mysqldump-d-B dbname1--tables tablename1 tablename2-uroot-p > Tablename.sql

9 exporting data from a single table in a database (no structure included)

Mysqldump-t dbname1 tablename-uroot-p > Tablename.sql

10 exporting data from multiple tables in a database (with no structure)

Mysqldump-t-B dbname1--tables tablename1 tablename2-uroot-p > Tablename.sql

11 exporting the structure and data of a table in a database

Mysqldump dbname1 tablename-uroot-p > Tablename.sql

12 exporting the structure and data of multiple tables in a database

Mysqldump-b dbname1--tables tablename1 tablename2-uroot-p > Tablename.sql

Stored Procedures & Function operations

1 export only stored procedures and functions (do not export structure and data, you need to use-D at the same time to export the structure)

Mysqldump-r-ndt dbname-u root-p > Dbname.sql

2 Export Events only

MYSQLDUMP-E-ndt dbname-u root-p > Dbname.sql

3 Do NOT export triggers (triggers are –triggers exported by default, export triggers using –skip-triggers masking)

mysqldump--skip-triggers dbname1-u root-p > Dbname.sql

Import the exported data into the database

Mysql-u root-p
Use dbname;
SOURCE Dbname.sql Summary:-D structure (--no-data: Do not export any data, only export database table structure)

-T data (--no-create-info: Export only data without adding a CREATE TABLE statement)

-N (--no-create-db: Export only data without adding the Create DATABASE statement)

-R (--routines: Export stored procedures and custom functions)

-E (--events: Export event)

--triggers (default export trigger, export using--skip-triggers mask)

-B (--databases: Export Database list, omit when a single library is available)

--tables table list (can be omitted when a single table)

① both the-D and-t at the same time when the structure and data are exported
② also do not export structure and data can be used-NTD
③ only export stored procedures and functions can use-R-NTD
④ Export All (structure & data & Stored Procedures & functions & events & Triggers) using-R-E (equivalent to ①, omitting-d-t; trigger default export)
⑤ only export Structures & functions & events & triggers using-R-E-D

Original link: https://www.cnblogs.com/yuzhoushenqi/p/7066317.html

Mysqldump Export Database Parameters detailed description

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.