MySQL master-slave synchronization basic Configuration

Source: Internet
Author: User

preparing: two MySQL databases

First, configure the primary database

1. Add Users

mysql> grant replication Slave on * * \

-e [email protected] "192.168.4.12" Authorized User/IP

-Identified by "111111"; Password


2. Start Binlog Log

[Mysqld]

Server_id=1

Log-bin=master1

binlog_format= "Mixed"


3. Restart the database service

[[Email protected] ~] #systemctl Restart Mysqld


4 Viewing log information

Mysql> Show master status;


Second, the configuration from the database

1. Verify the authorized users provided by the main library

[Email protected] ~]# mysql-h192.168.4.11-uslaveuser-p111111


2. Modify configuration file to specify configuration file

[Mysqld]

server_id=2

Log-bin=master2

3. Specify the main library information

mysql> Change Master to master_host= "192.168.4.11",

Master_user= "Slaveuser",

Master_password= "111111",

Master_log_file= "master1.000001",

master_log_pos=154;


4. Open service

mysql> start slave;


Close Service

mysql> stop Slave;

Delete Service

mysql> Reset Slave;


5. View

Mysql> show Slave status\g;


Slave_io_running:yes IO thread is running

Slave_sql_running:yesSQL thread is running


Multiple files from the database directory

[[Email protected] ~] #cat/var/lib/mysql/*

Master.info connecting master server information

Relay-log.info Interrupt log information

Host name-relay-bin.xxxxxx Interrupt Log

Bogon-realy-bin.index Interrupt Log index file


third, the test master-Slave synchronization configuration

1. Create a library on the primary server

mysql> CREATE DATABASE Ctoll;

2, from the server can also view


"One master and more from"

mysql> grant replication Slave on *. *

To

[email protected] "%"%---> Multiple hosts

Identified by "111111";


MySQL master-slave synchronization basic Configuration

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.