时间:2021-07-01 10:21:17 帮助过:16人阅读
1.在主库建立要同步的数据库,建立主库的帐号和修改主库配置
首先连接上数据库
mysql -S /tmp/mysql-3108.sock
创建测试同步的数据库,"create database sinatest;"
然后建立负责同步的用户
grant all on *.* to ali@"%" Identified by "abc111";
然后修改/data2/ali/mysql3308/my.cnf主库的配置,增加
binlog-do-db=sinatest
2.修改从库配置
然后修改/data2/ali/mysql3309/my.cnf从库的配置,增加
master-host=127.0.0.1
master-user=ali
master-password=abc111
master-port=3308
server-id=2
master-connect-retry=60
replicate-do-db=sinatest
log-slave-updates
3.重启mysql
先杀死mysql进程,然后再启动
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data2/ali/mysql3308/my.cnf --user=root &
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data2/ali/mysql3309/my.cnf --user=root &