MySQL Import and Export SQL scripts

Source: Internet
Author: User
MySQL Import and Export SQL scripts

MySQL export SQL scripts

  * It must be in D: \ ltsoft \ mysql4 \ bin> mysqldump-u root-P test> C: \ A. SQL

  First, go to the BIND directory of the mysqlinstallation directory (you can see mysqldump.exe). Generally, MySQL is installed in c: \ Program by default.  Files \ mysql \ MySQL Server 5.0

 * You cannot enter the MySQL command.

MySQL Export and Import SQL scripts

1. Export an SQL script

Mysqldump-u username-P Database Name> storage location
Mysqldump-u root-P test> C: \ A. SQL

      (The preceding Method for exporting SQL Scripts has been tested in person and succeeded !)

2. Import an SQL script

 Mysql-u username-P database name <storage location
 Mysqljump-u root-P test <c: \ A. SQL

 Note: The test database must already exist.

 Bytes

Instead of mysqldump for execution, the expected results were not obtained (expected results: the database Added tables and data according to the script ))

  Use the following 4th methods to import SQL scripts to the database.

Use Cases for MySQL Export Import commands

1. Export the entire database

Mysqldump-u username-P Database Name> exported file name

Mysqldump-u wcnc-P smgp_rj_wcnc> wcnc. SQL

  

2. Export a table

Mysqldump-u user name-P database name Table Name> exported file name

Mysqldump-u wcnc-P smgp_rj_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 adds a drop table before each create statement.

  

4. Import the database   (Tested successfully! Tables and data can be directly imported into the database from SQL scripts !)

Common source commands

Go to the MySQL Database Console,

For example, MySQL-u root-P

Mysql> Use Database

Then run the source command. The following parameter is the script file (for example,. SQL used here)

Mysql> source D: wcnc_db. SQL

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.