Some problems about the master-slave database unable to connect to the database in the mutual master-slave database setting

Time:2021-4-14

Some problems about the master-slave database unable to connect to the database in the mutual master-slave database setting
Step 1: start the database and input the login user name and password of the database;
1. Start the database:

1. Start command[ [email protected]  src]# systemctl  start  mariadb
2. Restart command[ [email protected]lhost  src]# systemctl  restart  mariadb
3. Closing command[ [email protected]  src]# systemctl  stop  mariadb
4. Set the starting time[ [email protected]  src]# systemctl  enable mariadb 
5. Turn off and start up[ [email protected]  src]# systemctl  disable mariadb 
6. Log in the database and input the user name and password

mysql -u -p;
Step 2: configure database permissions
1. Switch the specified database, such as mysql
Some problems about the master-slave database unable to connect to the database in the mutual master-slave database setting
Switch to MySQL database
Some problems about the master-slave database unable to connect to the database in the mutual master-slave database setting
2. Modify the database table
1) Check data sheet
show tables;
2) Query the host / root / password in the user table
Some problems about the master-slave database unable to connect to the database in the mutual master-slave database setting
3) Change host = “localhost” to “%”, this operation is to change the local IP access permission to any IP access!
Some problems about the master-slave database unable to connect to the database in the mutual master-slave database setting
4) Refresh database access
Some problems about the master-slave database unable to connect to the database in the mutual master-slave database setting

Step 3: configure firewall policy
Check firewall status:
firewall-cmd –state
Whether the firewall will be started automatically after power on
systemctl disable firewalld.service
systemctl enable firewalld.service

Manually switch off firewall
systemctl stop firewalld.service
systemctl start firewalld.service

Step 4: master slave library setting instruction
129 main library
SHOW MASTER STATUS;

130 slave Library

CHANGE MASTER TO MASTER_HOST=”192.168.126.129″,
MASTER_PORT=3306,
MASTER_USER=”root”,
MASTER_PASSWORD=”root”,
MASTER_LOG_FILE=”mysql-bin.000002″,
MASTER_LOG_POS=245;

START SLAVE;

SHOW SLAVE STATUS;

STOP SLAVE;