Simple use of mysqldump

Source: Internet
Author: User

Background

Need to make MySQL data synchronization, from a server to synchronize the database to another server, if you toss over, you know there is this thing--mysqldump, in fact, is a command of MySQL comes from

Operation Step 1. Meet Mysqldump

is generally MySQL installation directory/bin/, the command is also simple can be viewed through the mysqldump--help

2. Exporting SQL
/mysql/bin/mysqldump -u${username} -p${password} -h ${host} -P ${port} --quick  -d ${database_name} --skip-lock-tables > ${database_name}.sql

Replace the ${} with the desired value
The above statement means to say database_name This library is exported to Database_name.sql
and due to the addition of-D only the table structure is exported

3. Import SQL
/mysql/bin/mysql -u${username} -p${password} --database ${database_name} < ${database_name}.sql

Replace the ${} with the desired value

4. Think about the time when many libraries need to be dealt with.

Written in the form of a script, the idea is as follows:

    1. Organize the library names of the libraries you want to export into a TXT file, one library for each behavior;
    2. By traversing the files in 1 and then executing the command to export SQL one by one;
    3. Then, by traversing the TXT file in 1, execute the command to import SQL one by one;
      The specific script is as follows:
Off Topic

In fact, a lot of SQL Visualizer support Export import function, hahaha, in fact, very useful, but it is possible to deal with a large amount of data when inconvenient, use what efficiency is the most positive use is what, of course, the premise is your script will also, is not it?

Simple use of mysqldump

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.