master:10.88.12.89 (linux 5.0.22-log)
slave:10.88.12.79 (win 5.0.18-nt)
1、修改master的my.cnf
server-id=1
binlog-do-db=backup_db
log-bin=mysql-bin
然后们创建一个backup_db的数据库
CREATE DATABASE backup_db;
USE backup_db;
CREATE TABLE `backup_table` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(20) character set utf8 NOT NULL,
`sex` varchar(2) character set utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
给slave有权限登录
mysql>grant all on *.* to identified by 'root';
2、修改slave的my.ini文件
win服务器上,没有server-id之类的,所以就自己加了,具体如下:
server-id=2
master-host=10.88.12.89
master-user=root
master-password=root
master-port=3306
master-connect-retry=60
replicate-do-db=backup_db
注意,这里不用创建数据库,我创建了,反而报错了!
3、重启两服务器
master:
service mysql stop
service mysql start
slave:
net stop mysql
net start mysql
4、查看服务器状态
重启完了之后,先登录到slave
mysql>slave start;
现在就可以查看状态了,
master:
show master status;
slave:
show slave status;
完成!
阅读(1450) | 评论(0) | 转发(0) |