MySQL master-Slave synchronization configuration

Source: Internet
Author: User

MySQL master-Slave synchronization configuration


First, master server master configuration:

1, modify the My.ini, and then restart

[Mysqld]
Server-id=1 # Set the ID of the master machine (the ID must be unique between the master and slave machines and do not conflict with each other)
log-bin=mysql-bin# Open binary log and specify binary log with a filename prefix of Mysql-bin

Binlog-do-db = sync_db #只同步哪些库
Binlog-ignore-db = ignore_db# ignores which libraries

2, if the master server already has the data, the pilot out synchronizes to the slave
mysqldump-uuser_name-p123456 database_name > Outfile_name.sql


3. Create user, Backup authorization

CREATE USER ' slave ' @ ' slaveserver ' identified by ' slavepass ';
GRANT REPLICATION SLAVE on * * to ' SLAVE ';
Flush privileges;

4, view the binary file name and location, in the slave configuration needs

SHOW MASTER STATUS;

Second, from the server slave configuration

1, modify the My.ini, and then restart

[Mysqld]
server-id=2
Relay_log=mysql-relay-bin # Open relay log and specify relay log filename prefix Mysql-relay-bin (the contents of the relay log are from the binary log of master)
Replicate-do-table=wishrp.sku_map #库名. Table name

2. Import the existing data of master server;

3. Execute the synchronous statement
Change MASTER to
Master_host= ' Masterserver ',
Master_user= ' slave ',
Master_password= ' 123456 ',
Master_log_file= ' mysql-bin.000001 ',
Master_log_pos=1;

4. Start Backup

Start slave;
show slave status\g; #查看备份状态

Third, verification

On the master server to create new libraries, tables, additions and deletions to check the data, see Slave server synchronization effect.

MySQL master-Slave synchronization configuration

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.