Get the App
SLTechnology News&Howtos  ›  Database  › 

Let's talk about MySQL master-slave replication.

Shulou Source: shulou.com Published: 2022-06-01 06:59:21 10月01日 Update

Environment: win10 (there is little difference between linux and windows in terms of master and slave configuration), MySQL-5.7.16

1. First of all, we need two MySQL instances, which I have here are 3307 and 3308 respectively, of which 3307 is used as master,3308 as slave

two。 Modify the configuration my.ini of the master instance by adding two lines:

Ini code

[mysqld] log_bin = mysql-binserver_id = 3307 # server_id is optional but must be unique

3. Modify the configuration my.ini of the slave instance by adding two lines:

Ini code

[mysqld] log_bin = mysql-binserver_id = 3308 # server_id is optional but must be unique

4. Start master, log in, create a user replicant, and authorize:

I forgot to cut off the flush privileges; after authorization.

5. To check the master status, remember the first two items:

The master is over here, and it's best not to move the master before configuring the slave, because the Position may be changed.

6. Start slave. After logging in, execute:

7. View slave status:

Among them, Slave_IORunning and Slave_SQL_Running are both YES.

Even if the configuration is complete here.

test

Create new libraries, tables, and insert data on master:

Select data on slave: spot heavy oil

Http://www.wangchao.net.cn/hi/detail_232429.html

Http://www.wangchao.net.cn/hi/detail_232433.html

Http://www.wangchao.net.cn/hi/detail_232437.html

Http://www.wangchao.net.cn/hi/detail_232438.html

Http://www.wangchao.net.cn/hi/detail_232441.html

Http://www.365128.com/user/myx2/39.html

Http://www.365128.com/user/myx2/40.html

Http://www.365128.com/user/myx2/41.html

Http://www.365128.com/user/myx2/42.html

Http://www.365128.com/user/myx2/43.html

Http://www.365128.com/user/myx2/44.html

Http://www.365128.com/user/myx2/45.html

Http://www.365128.com/user/myx2/46.html

Http://www.365128.com/user/myx2/47.html

Http://www.365128.com/user/myx2/48.html

Http://site.leshou.com/s/33563826.html

Http://site.leshou.com/s/33563870.html

Http://site.leshou.com/s/33563896.html

Http://site.leshou.com/s/33563950.html

Http://site.leshou.com/s/33564004.html

Http://site.leshou.com/s/33564069.html

Http://site.leshou.com/s/33564112.html

Http://site.leshou.com/s/33564134.html

Http://site.leshou.com/s/33564165.html

Http://site.leshou.com/s/33564197.html

Tags: Configuration example code data login master-slave success not big two finished difference best state environment spot user heavy oil test Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology NVidia Shulou Information Microsoft