The following applies to the [MYSQLD] paragraph
Server-id= 1 This line must be, 1 can be other numbers, generally recommended is the IP last segment.
Log-bin=mysql-bin must have this, to turn on Binlog binary required.
Binlog-do-db=abc Optional, only synchronize the ABC database, with, number separated, you can synchronize multiple databases. Binlog-do-db write error causes Mysqld to fail to start, prompting for a PID file not found.
BINLOG-IGNORE-DB=ABC is optional and synchronizes databases other than ABC.
When configuring two mysqld on the same machine, when starting the second mysqld, run in the corresponding MySQL directory: Bin/mysqld_safe & can start successfully, start in Bin directory will fail, run in directory: Bin./mysqld_safe-- Defaults-file=. /MY.CNF--user=mysql & will fail, the MY.CNF configuration file cannot be loaded.
Start the second Mysqld method: Mysql-s/data/mysql2.sock-p123456 # Mysql-s The path of the second MySQL sock, password 123456
Close the second Mysqld method:
A. First find out the pid:ps of the second mysqld aux|grep 3307 #第二个mysqld我配置的端口为 3307
[[Email protected] ~]# PS Aux|grep 3307
MySQL 6136 0.0 71.2 1011252 352200 pts/0 Sl 13:55 0:03/soft/mysql/bin/mysqld--basedir=/soft/mysql--datadir=/d Ata/mysql--plugin-dir=/soft/mysql/lib/plugin--user=mysql--log-error=/data/mysql/kaka.err--pid-file=/data/mysql /kaka.pid--socket=/tmp/mysql.sock--port=3307
B. Kill 6136 #不能用kill-9 6136 to avoid loss of database data
8. When initializing the second MySQL database, the prompt does not have a my-default.cnf.
Cp/etc/my.cnf/soft/mysql2/support-files/my-default.cnf
VI/SOFT/MYSQL2/SUPPORT-FILES/MY-DEFAULT.CNF modifying the correct path and port for MYSQL2
9. Set Slave
A. Modify the my.cnf file, delete the line server-id=, or change to another, not the same as master.
B. Based on the configuration of master, add rows:
REPLICATE-DO-DB=ABC #同步数据库abc
#replicate-IGNORE-DB=ABC #同步除了abc以外的数据库
Configuring MySQL replication error logging