MySQL database implements master-slave synchronization data

Source: Internet
Author: User

MySQL Database implements master-slave synchronization data

Reference Links:

Http://www.cnblogs.com/wxf020412/archive/2007/09/25/905628.html

http://369369.blog.51cto.com/319630/790921

1. Description

Data synchronization is achieved using the data synchronization mechanism of the database itself, which can also be implemented by backing up the database directory and through third-party synchronization tools.

2. Prepare two + MySQL databases

①, best version consistent

3. Primary database Configuration

①, open mysql configuration file (Windows)my.ini or (Linux, typically in /etc/mysql/ directory)my.cnf

Under the mysqld node, configure the following:

[Mysqld]

# Master-Slave database data synchronization, a single configuration of a database synchronization, not write back the entire database

Binlog-do-db=refrigrator

# must be turned on

Log-bin=mysql-bin

#id, must , uniquely identify the server, typically The last byte of IP

server-id=203

②, turn on Master mode, authorize slave

# master server

GRANT REPLICATION SLAVE on * * to ' myaccount ' @ '% ' identified by ' 123456 ';

%: As long as the account password is correct can be used as the primary server slave, can be specific IP

③, command-line Input command: Displays the status of the primary database

Show Master status;

4, from the database configuration

①, in the mysqld node under the following configuration:

[Mysqld]

# Master-Slave database data synchronization, a single configuration of a database synchronization, not write back the entire database

# from database, query operation

replicate-do-db = Refrigrator

# open log, not required

Log-bin = Mysql-bin

# must, identify the server unique ID

Server-id =

②, turn on master-slave mode, configure this server to slave server

# from server

Change Master to

Master_host= ' 10.10.107.203 ', master_user= ' MyAccount ', master_password= ' 123456 ', master_log_file= ' mysql-bin.000002 ', master_log_pos=107;

Must be the same as the primary database Position,flie (show master status meaning)

③, check the state of slave:show slave status;

MySQL database implements master-slave synchronization data

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.