Append from MySQL

Source: Internet
Author: User
Tags ming create database

Append from MySQL:

Scenario: Add 1 from MySQL on a master-slave MySQL basis

Note:
This mode will lock the table at the time of backup, it is recommended to execute at night when no business is used.

Create an account with Sync permissions on the main MySQL

Mysql–u root–p ' xxxxxx '

Grant replication Slave on . to ' Ming ' @ ' 10.0.0.3 ' identified by ' xxxxxx ';
Flush privileges;
Exit

/usr/bin/mysqldump-u root-p ' xxxxxx '--routines--single_transaction--master-data=2--databases bugs >/backup1/ Bugs.sql

Note:
--routines: Exporting stored procedures and functions
--single_transaction: The transaction isolation state is set at the start of the export, and the transaction is started with a consistent snapshot, and then unlock tables, and Lock-tables is locked in a table that cannot be written until the dump is complete.
--master-data: The default equals 1, writes the dump start (change master to) Binlog point and POS value to the result, equals 2 is writes change master to the result and notes

On the import from MySQL:

Mysql-u root-p ' xxxxxx '

Create DATABASE bugs default character set UTF8;
Exit

Mysql-u root-p ' xxxx ' bugs >/space/bugs.sqlcat/space/bugs.sql | Head–n 30 (View master_log_file and master_log_pos information) mysql-u root-p ' xxxxxx '

Change Master to master_host= ' 10.0.0.2 ', master_user= ' Ming ', master_password= ' xxxx ', master_log_file= ' log.000241 ', master_log_pos=419123624;
Start slave;
show slave status \g;
If there are 1062 error classes can be ignored in the/ETC/MY.CNF (slave-skip-errors=1062), of course, not the error is the best, see Slave_io_running and Slave_sql_ Running yes to indicate that it is in normal sync
Exit

Append from MySQL

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.