1. Master-slave settings
host
log-bin=mysql-bin
server-id = 1
expire_logs_days = 5
binlog-do-db=dressale
binlog-do-db=ogotobuy
binlog-ignore-db=mysql
Second, mysql multiple instantiation
Copy the mysql directory
mysqld install mysql2 service installation
modify port
Registry modification
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/ project Find the service you just installed manually, add the path information of my.ini between mysql-nt" and mysql2, the format is:
--defaults-file="d:/mysql/my.ini"
from
server-id= 2
master-host=*.*.*.*
master-user=user
master-password=passwd
master-port=3306
replicate-ignore-db=mysql
replicate-do-db=db1
replicate-do-db=db2
The database needs to be consistent, from the master server to the slave server
Export database as sql command file
The first step is to flush all table and block write statements, and lock the COMMIT operation. Do not quit mysql here!
The second step is to start another terminal to export the data.
The third step is to check the status,
The fourth step is to release the lock state of the first step.
mysql>FLUSH TABLES WITH READ LOCK;
mysqldump --master-data=2 --single-transaction -u root -p labeyes >labeyes.sql
mysql>SHOW MASTER STATUS;
mysql>UNLOCK TABLES;
account setting
sqlyog*.*.*.* RELOAD, SUPER, REPLICATION SLAVE
start from server command
slave stop;
show variables like 'server_id';
set global server_id=2;
CHANGE MASTER to MASTER_HOST='*.*.*.*', MASTER_PORT=3306, MASTER_USER='user', MASTER_PASSWORD='passwd', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=1;
MASTER_LOG_FILE MASTER_LOG_POS is obtained by executing show master status on the master
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; execute when setting synchronization error
slave start;
show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
represents success