Use mysqldump to export (back up) Mysql Data

Source: Internet
Author: User

Documentation for mysqldump: http://dev.mysql.com/doc/refman/5.1/zh/client-side-scripts.html#mysqldump


Mysqldump
It is most commonly used to back up an entire database:

shell> mysqldump db_name >backup-file.sql


You can read the dump file back to the server as follows:

Shell>MySQLDb_name<Backup-file. SQL
Correspondingly, the command to import data to the target server is:
Shell>Mysqladmin create target_db_name
Shell>MySQL target_db_name <backup-file. SQLThe following example dumps the replication_test database to the D:/replication_test. SQL file and adds drop table if exists to the generated SQL statement.
Mysqldump-u root-proot -- add-drop-database -- add-drop-Table replication_test> D:/replication_test. SQL

The following are some common simple usage methods:
1. Export the entire database
Mysqldump-u username-P Database Name> exported file name
2. Export a table
Mysqldump-u user name-P database name Table Name> exported file name
3. Export a database structure
Mysqldump--U username-P database name -- no-Data-- Add-drop-database -- add-drop-tableSmgp_cmd_wcnc> D:/wcnc_db. SQL
-- No-data: no dump database, -- add-drop-database add a drop database before creating the database -- add-drop-table add a drop table before each create statement



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.