Mysql database addition slave database mysql Master/Slave configuration has been applied in a lot of businesses. Although I know about the mechanism, I have never processed it. For more information, I have performed Master/Slave configuration on mysql: 3306 slave Database: 33071 master database configuration: www.2cto.com My. conf code [mysqld] # log-bin =/data0/mysql/3306/binlog log-bin-index =/data0/mysql/3306/binlog /binlog. index server-id = 1 # the configuration of the slave database cannot be the same as that of the master database. Note: Check whether binlog-do-db exists in the original configuration file. If the database is specified, only this database can perform master-slave operations. Users who need to configure (restart the service) to add REPLICATION permissions (read binary files) as needed: grant replication slave, replication client on *. * TO 'username '@ 'IP' identified by 'Password'; Java code mysql> show master status; View file and position www.2cto.com
2 slave Database Configuration: My. conf code [mysqld] # configure relaylog. If you do not have relaylog, create the directory relay-log-index =/data0/mysql/3307/relaylog # relay- log-info-file =/data0/mysql/3307/relaylog # relay log file replicate-ignore-db = mysql # Shield mysql synchronization, multiple applications can be set ", "Separate server-id = 2 # different from the master database configuration. Similarly, you must note that the binlog-do-db configuration www.2cto.com restarts the Service database to operate Mysql code mysql> change master to master_host = 'master database ip Address ',> master_port = 3306,> master_user = 'user name ',> Master_password = 'Password',> master_log_file = 'binlog. * ** ',> master_log_pos = 101; www.2cto.com master_log_file and master_log_pos are queried in the master database and then: Mysql code mysql> slave start; # view slave database status mysql> show slave status \ G; information: Slave_IO_Running: Yes Slave_ SQL _Running: Yes indicates that the configuration is successful and whether the synchronization of data written to the master database from the slave database is successful.