Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set Master-Slave synchronization in MYSQL Database

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to set master-slave synchronization in MYSQL database, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Configure the master database

Main master: 192.168.1.132

From slave: 192.168.1.133

1) Authorization to slave database GRANT REPLICATION SLAVE ON *. * to 'repl'@'192.168.1.132' identified by' test123456';FLUSH PRIVILEGES

2) modify the configuration file of the main library, enable binlog, and set server-id. After each modification of the configuration file, you have to restart the mysql service before it takes effect.

Vim / etc/my.cnf

ID number on the server-id:master side

Log-bin: the log path and file name of the synchronization, if mysql has permission to write to this directory

Binlog-do-db: name of the database to be synchronized

3) authorization

Chown mysql:mysql-R / usr/local/mysql_data

4) restart the service:

Service mysqld restart

5) enter the following statement

Show master status

2. Configure the slave database

1) set configuration from database

Vi / etc/my.cnf

Server-id

Replicate-do-db=world

2) add the address, port number, synchronization user, password, log file, file start location of the master database.

3) Delete auto.cnf

Cd / usr/local/mysql_data/ rm-rf auto.cnf

(synchronization will not succeed if you do not delete)

4) start the slave database master and slave

Show slave status

5) insert data in the master data, and the slave data is synchronous data.

The above is how to set master-slave synchronization in MYSQL database. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report