Mysqldump-h host-u username-p Database Name> exported database name. SQL
Mysqldump-h host-u user name-p database name Table Name> exported table name. SQL
Several common parameters are as follows:
-P or -- port: the server port to be connected. this parameter is required if MySQL port is not 3306.
-D or -- no-data does not have detailed data. Only the data structure is exported.
-- Add-drop-database: when creating a database, first drop the existing database with the same name [usually after the-d parameter]
-- Add-drop-table when creating a table, drop the existing table with the same name first [usually after the-d parameter]
The following uses the emlog database as an example to export data.
1. Export all data of the entire emlog database (including data structures, including data)
Mysqldump-h127.0.0.1-u root-p emlog> emlog_all. SQL
2. Export emlog_blog table (including table structure and table data)
Mysqldump-h 127.0.0.1-u root-p peerrecom> peerrecom. SQL
3. Only export the database structure
Mysqldump-h127.0.0.1-uroot-p-d -- add-drop-table emlog> emlog_all_structure. SQL
4. Only export the table structure
Mysqldump-h127.0.0.1-uroot-p-d -- add-drop-table emlog emlog_blog> emlog_blog_structure. SQL
There are many ways to import data. The most single command is the source command. Use the mysql command to connect to the database, and then use the source command to import the files in the specified path.
Connect to MySQL
Mysql-h127.0.0.1-uroot-p
Create a database first, because the exported file does not contain statements for creating a database. If the database has been created, you do not need to create a database.
Create database emlog COLLATE 'utf8 _ general_ci ';
Switch Database
Use emlog;
Import a specified SQL File
Mysql> source/path/.../source. SQL
From a strange blog