Mysql Master Slave Config, mysqlslave
Install two or more MySQL services on the same machine:
Download the mysql installation package. After the installation is complete, copy multiple copies of the installation folder on the disk. Enter my. ini modify port (port cannot conflict), server_id, basedir (optional), datadir (data file path) and other parameters;
# Path to the database root
Datadir = "D:/MySQL Server 5.7/data /"
# General and Slow logging.
Log-output = FILE
General-log = 1
General_log_file = "VIPSH-20140721I.log"
Slow-query-log = 1
Slow_query_log_file = "VIPSH-20140721I-slow.log"
Long_query_time = 2
# Binary Logging.
# Log-bin
Server_id = 54
Log_bin = D:/MySQL Server 5.7/data/EricSun-mysql-bin.log
Log_bin_index = D:/MySQL Server 5.7/data/EricSun-mysql-bin.index
Max_binlog_size = 256 M
Expire_logs_days = 30
#===== Slave server needs to be configured ====
Relay_log = EricSun-mysql-relay-bin
Log_slave_updates = 1
Read_only = 1
# Error Logging.
Log-error = "VIPSH-20140721I.err"
Note: You must delete auto when copying and installing folders. cnf. Otherwise, The following error occurs when starting slave: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UIDs must be different for replication to work.
After the preceding steps, run the cmd command to install the windows service: mysqld -- install MySQLXY -- defaults-file = "C: \ Program Files \ MySQL Server X.Y \ my. ini"
After the installation is successful, start different mysql services;
Log on to different mysql instances, enter show master status \ G, view master server status, enter show slave status \ G, and view slave server status;
Then, from the server CMD window, set: change master to master_host = 'localhost', master_user = 'root', master_password = 'root', master_log_file = 'mysql-bin.000001 ', master_log_pos = '0 ';
Then enter show slave status \ G again; To View
Slave_IO_Running: Yes
Slave_ SQL _Running: Yes
The background thread runs YES.
CRUD is performed on the master database, and the slave database is updated.