Examples of mysqldump exports importing all libraries, some libraries, some tables
1 Export all libraries
Mysqldump-uusername-ppassword-- all-databases > all.sql
2 Import all libraries
Mysql > source all.sql
3 Export some libraries
Mysqldump-uusername-ppassword-- databases db1db2 > db1db2.sql
4 Import some libraries
Mysql > source db1db2.sql
5 Export a single library
Mysqldump-uusername-ppassword-- databases db1 > db1.sql
6 Import a single library
Mysql > source db1.sql
-- there seems to be no way to import only the db1 library directly using the db1db2.sql file in step 3.
7 Export some data tables
Mysqldump-uusername-ppassword db1 table1 table2 > tb1tb2.sql
8 Import some data tables
Mysql-uusername-ppassword db1
< tb1tb2.sql 或 mysql>Source tb1tb2.sql
9 mysqldump character set Settings
Mysqldump-uusername-ppassword-- default-character-set=gb2312 db1 table1 > tb1.sql
The mysqldump export file comes with create table by default, and if-- all-databases or-- databases, it comes with create database by default
-- tables only imports tables, not libraries.-- even if databases is added to tables, the exported file does not have create database.
-tables:Overrides option-databases (- B)
1. Export all libraries
Mysqldump-- all-databases > all.sql
Export all tables for all databases
For such export files, there are create database options and create table options.
2. Export some libraries
Mysqldump test1 > / home/test1.dmp
Export only test1 databases
For such an export file, there is no create database option, only the create table option
Mysqldump-- databases test1 > / home/test1new.dmp
Export only test1 databases
For such export files, there are create database options and create table options.
3. Export some tables
Mysqldump test1 tab1 > / home/tab1.dmp
Export only tab1 tables in the test1 library
For such an export file, there is no create database option, only the create table option
Mysqldump test1-- tables tab1 > / home/tab--1.dmp
Export only tab1 tables in the test1 library
For such an export file, there is no create database option, only the create table option
Mysqldump-- databases test1-- tables tab2 > / home/tab2.dmp
Export only tab2 tables in the test1 library
For such an export file, there is no create database option, only the create table option
Mysqldump-- databases test1-- tables tab1 tab2 > / home/tab1_tab2.dmp
Export only tab1 and tab2 tables in the test1 library
For such an export file, there is no create database option, only the create table option
Examples of import and export of cloud database
Export rm-6.mysql.rds.aliyuncs.com:3306 's msus_ SVC library, and then import rm-7.mysql.rds.aliyuncs.com:3306 's msus library. The msus library already exists.
Export msus_ SVC library
Mysqldump-hindrmmur6.mysql.rds.aliyuncs.com'-P3306-uprocess6-pendant XX' msus_svc > / home/slave/msus_svc.sql
Import msus Library
Mysql-hobrmmer7.mysql.rds.aliyuncs.com'-p3306-uprocess7-pauxx' msus