1 回答

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超6個(gè)贊
mysql的主從復(fù)制可以通過如下方式實(shí)現(xiàn)。
master
在master主機(jī)上修改配置文件,比如通常是修改my.cnf。
[mysqld]
server-id=1
log-bin
在mysql上創(chuàng)建同步賬號(hào)并授權(quán)。
如下,創(chuàng)建用戶名為repl,密碼為1234567:
create user 'repl'@'%' identified by '1234567';
如下,給repl用戶授權(quán)允許同步:
grant replication slave on *.* to 'repl'@'%' identified by '1234567';
slave
同樣,在slave主機(jī)上修改配置文件。
[mysqld]
server-id=2
log-bin
接著配置如下,其中x.x.x.x為master主機(jī)ip地址。
change master to master_host='x.x.x.x',master_user='repl',master_password='1234567';
注意server-id為主機(jī)標(biāo)識(shí),不能重復(fù)。
- 1 回答
- 0 關(guān)注
- 696 瀏覽
添加回答
舉報(bào)