MySQL database Common Export Import Command mysqldump introduction

Source: Internet
Author: User
Tags import database

Mysqldump Export Command Base usage

The code is as follows Copy Code

Mysqldump-u username-P [--opt] DATABASENAME [Table] > Export SQL file name

The default mysqldump exported SQL file contains not only the exported data, but also the structure information of all the data tables in the exported database


1. Export the entire database

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

The code is as follows Copy Code

C:Program filesmysqlmysql Server 5.1bin>mysqldump-u root-p--opt MySQL >d:phpwebsqlbackupmysql.sql

Enter Password: Hu Jintao

2. Export a table

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

The code is as follows Copy Code

C:Program filesmysqlmysql Server 5.1bin>mysqldump-u root-p--opt mysql user >d:phpwebsqlbackupmysql_user.sql

Enter Password: Hu Jintao

3. Export a database structure

The code is as follows Copy Code

Mysqldump-u wcnc-p-d–add-drop-table SMGP_APPS_WCNC >d:wcnc_db.sql

-D No data –add-drop-table add a drop table before each CREATE statement

4. Import Database

Common source Commands
Enter the MySQL database console,

such as Mysql-u root-p

The code is as follows Copy Code

Mysql>use Database

Then use the source command, followed by the script file (such as the. SQL used here)

The code is as follows Copy Code
Mysql>source D:linuxzg.sql


more mysqldump command Parameters

In addition, SQL files exported using mysqldump are saved in the bin directory by default if they are not with an absolute path.

–opt: This mysqldump command parameter is optional, if this option is used to activate the quick,add-drop-table,add-locks,extended-insert,lock-tables parameter of the mysqldump command, That is, you do not need to append these parameters when using mysqldump to export MySQL database information through the –opt parameter.

–quick: On behalf of ignoring buffered output, the mysqldump command exports data directly to the specified SQL file.

–add-drop-table: As the name suggests, is to add drop-table IF exists statement before each create Tabel command to prevent the duplicate of the data table.

–add-locks: means locking and unlocking specific data tables before and after the insert data, you can open mysqldump exported SQL files, and the lock tables and unlock tables appear before the insert.

–extended-insert (-E): This parameter indicates that multiple rows can be inserted.

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.