Mysql > create mysql master/slave for the first time

1. Install centos7 on the vm

  1. The installation of virtual machine, vmware is really rubbish, still stuck, after a day to change the Virtual box is very smooth
  2. Centos7 is installed on the VM. There are two centos servers installed.

    After the installation and configuration of the network, I can connect to the external network, but I can not connect with finalshell

    First, right click on this, select network card 2 (mainly to shut down the server), select host-only, then you can communicate with the host and use itip addrYou can see the virtual machineNetwork IP (192.168. *. *)the

2. Install mysql8 for centos

Install mysql 2.1

Download the package:

Wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm local installation: # yum install mysql80-community-release-el7-1.noarch. RPM # yum install mysql80-community-release-el7-1.noarch. RPM Mysql: systemctl start mysqld systemctl daemon-reload mysql: systemctl start mysqld Mysql: grep ‘temporary password’ /var/log/mysqld.log Mysql -uroot -p will prompt you to enter the password. Enter the temporary password to log in. Change the mysql password, or the next step will force you to change the password:

# localhost if needed elsewhere, such as: % ALTER USER 'root'@'localhost' IDENTIFIED BY '121b33dAj934J1^Sj9ag'; % ALTER USER 'root'@'localhost' IDENTIFIED BY '121b33dAj934J1^Sj9ag'Copy the code

Mysql8 default password strength requirements, you need to set a complex, otherwise the error will be displayed. Refresh the configuration: FLUSH PRIVILEGES;

See this link for details on master-slave setup, where errors are recorded

If Slavei Running is Connecting, there are 4 reasons:

1, the network is abnormal, check IP port 2, password error, check the user name and password for synchronization 3, pos error, check the Master Position 4, mysql8 unique password rule error

Here’s another reason

5. It is possible that the firewall is not turned off. Since I am a local VM, I directly turn off the firewall on the VM

If Slave_SQL_Running: No

It may be caused by a slave restart or transaction rollback

mysql> slave stop;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> slave start;
Copy the code

SQL > alter database run (master); SQL > alter database run (master); SQL > alter database run (master)

Mysql master-slave setup principle and process