MySQL Master from

Source: Internet
Author: User

Ubuntu Server mysql5.9

The Enable function edits the MySQL configuration file on the master and slave server separately

#vim/ETC/MYSQL/MYSQL.CONF.D/MYSQLD.CNF Add the following two lines

bind-address = 0.0.0.0 #修改为允许任意服务器访问

Log-bin=mysql

Server-id=1 #主从数字不一样

Restart Service

#/etc/init.d/mysql restart

Go to MySQL

To build user permissions

Mysql>grant all privileges on * * to [e-mail protected] '% ' identified by ' 123 ';

Mysql>show Master status;

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/17/083df2f1cf61f7b735029acfa1fc252d.jpg-wh_500x0-wm_3 -wmp_4-s_3291888915.jpg "title=" 1.jpg "alt=" 083df2f1cf61f7b735029acfa1fc252d.jpg-wh_ "/>

1, first in the main lock, pay attention to lock after looking at the master state, to ensure that file and position unchanged.

Mysql>FLUSH TABLES with READ LOCK;

Mysql>unlock tables; #解锁在同步完成之后

2. Add Master from top

Mysql>change Master to master_host= ' 192.168.1.141 ', master_user= ' user ',

Master_password= ' 123 ',

master_port=3306,

Master_log_file= ' mysql.000002 ',

master_log_pos=154;

View the status of slave

mysql>stopslave;

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/17/c40843c21fca84571103e0ba4e34298a.jpg-wh_500x0-wm_3 -wmp_4-s_2796922869.jpg "title=" 2.jpg "alt=" C40843c21fca84571103e0ba4e34298a.jpg-wh_ "/>

Slave_io_runing:yes
Slave_sql_ringing:yes

Normal

If no is present, look at the database log for errors

Slave SQL for channel ': Error Executing row event: ' Table ' yunceshi.ph_smart_contract ' doesn ' t exist ', error_code:1146

Add slave-skip-errors = 1146 in config file

You can also take a backup of your database and import it into the database you are importing from.

MySQL Master from

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.