Article reprint: http://www.cnblogs.com/chevin/p/5683281.html
———————————————-Library Operation ———————————————-
1.① Exporting a library structure
mysqldump-d dbname-u root-p > Xxx.sql
② Exporting Multiple library structures
mysqldump-d-B dbname1 dbname2-u root-p > Xxx.sql
2.① Exporting a library data
mysqldump-t dbname-u root-p > Xxx.sql
② Exporting Multiple library data
Mysqldump-t-B dbname1 dbname2-u root-p > Xxx.sql
3.① Export a library structure and data
mysqldump dbname1-u root-p > Xxx.sql
② export Multiple library structures and data
mysqldump-b dbname1 dbname2-u root-p > Xxx.sql
———————————————-Table Operation ———————————————-
4.① Export a table structure
mysqldump-d dbname1 tablename1-u root-p > Xxx.sql
② Exporting multiple table structures
mysqldump-d-B dbname1--tables tablename1 tablename2-u root-p > Xxx.sql
5.① Exporting a table data
mysqldump-t dbname1 tablename1-u root-p > Xxx.sql
② Exporting multiple table data
mysqldump-d-B dbname1--tables tablename1 tablename2-u root-p > Xxx.sql
6.① Export a table structure and data
mysqldump dbname1 tablename1-u root-p > Xxx.sql
② Export multiple table structures and data
mysqldump-b dbname1--tables tablename1 tablename2-u root-p > Xxx.sql
———————————— – Stored Procedure & function Operations ————————————-
7. 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 dbname1-u root-p > Xxx.sql
———————————————-Event Action ———————————————-
8. Export only Events
mysqldump-e-ndt dbname1-u root-p > Xxx.sql
————————————— – Trigger Action —————————————— –
9. Do not export triggers (triggers are –triggers exported by default, export triggers using –skip-triggers masking)
mysqldump--skip-triggers dbname1-u root-p > Xxx.sql
————————————————————————————————
10. Import
Mysql-u Root-p
Use game;
source Xxx.sql
———————————————————————————— ————
summary:
-d structure (--no-data: Do not export any data, export only database table structure)
-t data (--no-create-info: Export data only, Instead of adding the Create TABLE statement)
-n (-- NO-CREATE-DB: Export data only, without adding create DATABASE statement)
-r (--routines: Exporting stored procedures and custom functions)
-e (--events: Export event)
--triggers (default export trigger, export using--skip-triggers mask)
-b (--databases: Export Database list, can be omitted when a single library)
--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
PS: If you can use the relevant tools, such as the official MySQL Workbench, import and export is very convenient, such as. (Of course, for security, the general situation is to shield the external operation rights, so the need to use the command is more)
MySQL mysqldump Import/Export structure & data & Stored Procedures & functions & events & Triggers