MySQL database import and Export

Source: Internet
Author: User

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)

  

Related Article

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.