Mysql master-slave replication and mysql master-slave Replication
Mysql master-slave replication step 1) download MySQL (Ubuntu) sudo apt-get install mysql-server mysql-client2) Change mysql configuration file vi/etc/mysql/my. the cnf modification content is as follows # bind the local IP address, as master bind-address = 192.168.0.75 # As master server-id = 1 # Remove comment log_bin =/var/log/mysql/mysql-bin.log # binlog_do_db = zm_gaiay_net_cn save change 2) restart mysql sudo service mysql restart3) enter the command line mysql-u root-p through mysql client and prompt to enter the root password 4) grant the copy permission to slave_user and specify the password grant replication slave on *. * to 'slave _ user' @ '%' identified by '000000'; 5) connect to the database corresponding to binlog_do_db (zm_gaiay_net_cn) use zm_gaiay_net_cn; 6) lock the table to avoid new changes. flush tables with read lock; 7) view master status show master status; + metric + ---------- + -------------- + ---------------- + | File | Position | Binlog_Do_DB | usage | + usage + ---------- + -------------- + usage + | mysql-bin.000001 | 107 | usage | + usage + ---------- + -------------- + ------------------ + file and position will be used in the slave database to install 1) install mysql 2) Change the mysql configuration file my. cnf server-id = 2 # add, note that here is the underlined replay-log =/var/log/mysql/mysql-replay-bin.log log_bin =/var/log/mysql/mysql-bin.log binlog_do_db = zm_gaiay_net_cn 3) Restart service sudo service mysql restart4) use mysql-client TO enter the command line interface mysq-u root-p TO configure the MASTER database change master to MASTER_HOST = '2017. 168.0.75 ', MASTER_USER = 'slave _ user', MASTER_PASSWORD = '000000', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 123456; Explanation master_host: master database ip master_user: master_password used to copy the user in the group Library: the user password master_log_file used to copy in the master database: The binfile master_log_pos corresponding to the master database (zm_gaiay_net_cn): Where to start replication 5) start replication slave 6) view the SHOW SLAVE STATUS