Mysql master-slave configuration, mysql master-slave Configuration

Source: Internet
Author: User

Mysql master-slave configuration, mysql master-slave Configuration

There can be many slave databases. We assume one master M and one slave S.

 

Add the master M configuration file:

Server-id = 1

Bin-log = logbin

This name is random

Remember to restart

 

Add from S configuration file:

Server-id = 2

 

The configuration file is complete.

 

Run the following command on the master M client:

> Show master status;

File and Position, for example, logbin.000001 120

 

Run the following command on the slave S client:

> Change master to master_host = 'master address of master s', master_user = 'account with synchronization and replication authorization', master_password = 'Password', master_log_file = 'logbin. 000001 ', master_log_pos = 120;

Synchronization REPLICATION permission refers to replication slave.

Example SQL:

> Grant replication slave on *. * to 'user' @ 'localhost' identified by 'pwd ';

> Flush privileges;

Enable slave S:

> Start slave;

 

View slave S status:

> Show processlist;

 

Complete.

 

Master-slave backup is the command automatically executed by the master M machine on the slave S machine, so if M already has a database that S does not have, your operations on the database will cause synchronization replication to fail. Therefore, we recommend that you use a clean mysql instance for backup.

Stop slave backup in slave S: stop slave; clear: reset slave;

 

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.