Mysql master-slave replication and mysql master-slave Replication

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.