MySQL data, when used, always encounter the import and export situation, so how to import and export correctly, it is very important! The following methods are used in the work, regardless of the supplement:
Import:
Import directly in MySQL:
Mysql>use DatabaseName;
mysql> load Data infile ' filePath ' into table ' TableName '
If you are using SQL script files directly, you can use Source:
Enter the MySQL database console, such as Mysql-u root-p
The Mysql>use database then uses the source command, followed by the script file (for example, the. SQL used here)
Mysql>source D:\wcnc_db.sql Export:
Export from a Linux terminal or Shell window, or from a command prompt:
MySQL [-H ip-p Port]-u username-p Password DatabaseName "SELECT * from TableName [where]" > Filepathname
You can also use mysqldump, several common use cases are as follows:
1. Export the entire database
Mysqldump-u user name-p database name > exported file name
Mysqldump-u wcnc-p SMGP_APPS_WCNC > Wcnc.sql
2. Export a table
Mysqldump-u user name-P database name Table name > exported file name
Mysqldump-u wcnc-p SMGP_APPS_WCNC users> wcnc_users.sql
3. Export a database structure
Mysqldump-u Wcnc-p-D--add-drop-table smgp_apps_wcnc >d:\wcnc_db.sql-d No data--add-drop-table add a drop before each create statement Table
in MySQL, the export operation is performed:
SELECT * into outfile ' fileName ' from TableName [where ...] (Export some or all of the data in the table)