mysql主从数据库配置有复杂的有简了,下面我们来给各位简单的介绍一下mysql主从数据库配置吧,希望能帮助到各位.
主:配置my.conf:
- log-bin=mysql-bin
- server-id = 1
- binlog-do-db=jinrimingpin_com
- binlog-do-db=jinripinpai_com
- binlog-do-db=jinritemaihui_com
- binlog-do-db=mingpintejia_com
binlog-do-db 是允许同步的数据库,一行一个.
SHOW MASTER STATUS
mysql-bin.000001 4658 下面设置从库要用 change master to
然后导数据到从库,新建一个可让从库访问的账号.
grant replication slave on *.* to “congku”@”xxxx” identified by “密码”;
flush privileges;
从:配置my.conf
- server-id = 2
- replicate-do-db=mingpintejia_com
- slave_skip_errors = 1062,1032
从库要同步的数据库 replicate-do-db.
mysql -u congku -p -h xx.xx.xx.xx 检测是否可以连接主服务器.
- slave stop;
- CHANGE MASTER TO
- MASTER_HOST=’xxx’,MASTER_USER=’congku’,MASTER_PASSWORD=’密码’,MASTER_LOG_FILE=’mysql-bin.000002′,MASTER_LOG_POS=102470;
- start slave;
- 确保:
- Slave_IO_Running: Yes
- Slave_SQL_Running: Yes
|