How to export data using the mysqldump command

Source: Internet
Author: User
In normal mysql applications, there are always many ways to import and export data. This article mainly introduces how to use the mysqlmysqldump command to import and export data. it is helpful to everyone.

In normal mysql applications, there are always many ways to import and export data. This article mainly introduces how to use the mysqlmysqldump command to import and export data. it is helpful to everyone.

The mysqldump command carries the -- where/-w parameter, which is used to set the data export conditions. The usage is basically the same as that in the SQL query command, we can export the data you need from the database.

1. the command format is as follows:

Mysqldump-u user name-p password database name table name -- where = "filter condition"> Export file path

Example:

Export data with an id greater than 100 from the test_data table of the test database to the/tmp/test. SQL file.

The code is as follows:

Mysqldump-uroot-p123456 test test_data -- where = "id> 100">/tmp/test. SQL


2. export the entire database

Mysqldump-u username-p database name> exported file name

The code is as follows:

Mysqldump-u wcnc-p smgp_rj_wcnc> wcnc. SQL


3. export a database structure

The code is as follows:

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.


Mysqldump conditions

Mysqldump-u username-p password-h host Database a-w "SQL condition"-lock-all-tables> path

The code is as follows:

1 mysqldump-hhostname-uusername-p dbname tbname> xxxx. SQL
** Export the database table content based on the specified conditions. (-W option-where)

1 mysqldump-hhostname-uusername-p dbname tbname-W' id> = 1 and id <= 10000 '-- skip-lock-tables> xxxx. SQL
Or

1 mysqldump-hhostname-uusername-p dbname tbname -- where = 'unit _ id> = 1 and unit_id <= 10000 '> ~ /Xxxx. 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.