MySQL Replication database

Source: Internet
Author: User

MySQL Replication database

To make it easy to copy a database quickly, you can use the following command
Copy the data from the DB1 database and the table structure to the NEWDB database

Create a new database

#mysql -u root -p123456mysql>CREATE DATABASE `newdb` DEFAULT CHARACTER SET UTF8 COLLATE UTF8_GENERAL_CI;

Copy database, use mysqldump and MySQL command combination to complete replication at once

#mysqldump db1 -u root -p123456 --add-drop-table | mysql newdb -u root -p123456

Note the-p123456 parameter:-P followed by the password directly, no space in the middle)

The above is the method of replicating the database on the same MySQL server. If you are copying to a remote other MySQL server, you can use the "-H hostname/IP" parameter of MySQL. The premise is that MySQL allows remote connections, and the transfer efficiency and time of remote replication are acceptable.

Not on the same MySQL server

#mysqldump db1 -uroot -p123456 --add-drop-table | mysql -h 192.168.1.22 newdb -u root -p123456

MySQL Replication database

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.