MySQL Import and Export SQL scripts-export the first n data records in the table

Source: Internet
Author: User
Tags mysql import

From: http://blog.csdn.net/xiaoyu411502/article/details/5319232

First, use the mysqldump command only if you enter the bin directory under the MySQL installation directory in cmd.
My MySQL is installed on the E: disk. Therefore, first go to the bin directory:
E:/program files/MySQL Server 5.0/bin>
Then, you can use this command.

 

1. Export the entire database

Mysqldump-u username-P Database Name> storage location

For example:
Mysqldump-u root-P project> C:/a. SQL

(The exported project database has been tested in person and is successfully exported !)


 

2. Export the structure of a table with the data in the table

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

Mysqldump-u root-P project position> C:/a. SQL

(Test, successful !)

 

Export only the table structure without the data in the table:

Mysqldump-D-u root-P project position> C:/a. SQL

(Test, successful !)


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

Common source commands
Go to the MySQL Database Console,
D:/program files/MySQL Server 5.1/bin> mysql-u root-P
D:/program files/MySQL Server 5.1/bin> mysql> Use 'database'
Then run the source command. The following parameter is the script file (for example,. SQL used here)
D:/program files/MySQL Server 5.1/bin> mysql> source D: wcnc_db. SQL

5. Remotely export the database

The command is as follows:

Mysqldump-H 192.168.11.210-u root-P test> C:/test. SQL

 

Export the first 100 data records of a table

Local: mysqldump-u root-P password "-W 1 limit 100" microlens_dev> microlens. SQL

Remote: mysqldump-h192.168.135.200-u root-P "-W 1 limit 100" microlens_dev> microlens. SQL

From: http://blog.csdn.net/xiaoyu411502/article/details/5319232

First, use the mysqldump command only if you enter the bin directory under the MySQL installation directory in cmd.
My MySQL is installed on the E: disk. Therefore, first go to the bin directory:
E:/program files/MySQL Server 5.0/bin>
Then, you can use this command.

 

1. Export the entire database

Mysqldump-u username-P Database Name> storage location

For example:
Mysqldump-u root-P project> C:/a. SQL

(The exported project database has been tested in person and is successfully exported !)


 

2. Export the structure of a table with the data in the table

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

Mysqldump-u root-P project position> C:/a. SQL

(Test, successful !)

 

Export only the table structure without the data in the table:

Mysqldump-D-u root-P project position> C:/a. SQL

(Test, successful !)


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

Common source commands
Go to the MySQL Database Console,
D:/program files/MySQL Server 5.1/bin> mysql-u root-P
D:/program files/MySQL Server 5.1/bin> mysql> Use 'database'
Then run the source command. The following parameter is the script file (for example,. SQL used here)
D:/program files/MySQL Server 5.1/bin> mysql> source D: wcnc_db. SQL

5. Remotely export the database

The command is as follows:

Mysqldump-H 192.168.11.210-u root-P test> C:/test. SQL

 

Export the first 100 data records of a table

Local: mysqldump-u root-P password "-W 1 limit 100" microlens_dev> microlens. SQL

Remote: mysqldump-h192.168.135.200-u root-P "-W 1 limit 100" microlens_dev> microlens. SQL

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.