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 realize synchronization in MySQL Database

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about how to achieve synchronization in the MySQL database, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

1. Modify the my.cnf on the master side to add configuration parameters:

[MySQL (the best combination with PHP)]

Log-bin

Server-id=1

two。 Modify the my.cnf on the slave side to add configuration parameters:

Log-bin

Mastermaster-host=master

Master-user=rep

Master-password=rep

Master-port=3306

Server-id=2

The above parameters are the most basic configuration, do not explain more, solve the potential initialization data.

1. Empty all binlog on the master, back up the existing binlog if it is useful, and then package all the data files on the master, including the ibdata files.

two。 A similar method clears all binlog on slave and copies the data file package on master to its own data file directory.

Start master and add a new rep user

"grant all privileges on *. * to rep@% identified by rep; flush privileges

Start slave to check whether the MySQL database synchronization is successful.

In general, the reason for the unsuccess is that the slave failed to locate the binlog after connecting to the master, so you need to set the binlog of both sides to the same, and then stop slave; start slave;.

The above is how to achieve synchronization in the MySQL database. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please 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

Database

Wechat

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

12
Report