1. test environment:
> Master: physical machine, Debian (testing) + mysql5.0 + ip: 192.168.40.223
> Slave: Virtual Machine, CentOS (4.0) + mysql5.0 + ip: 192.168.40.225
2. Modify the Master (192.168.40.223)
1). Modify/etc/mysql/my. cnf
Make the following changes in [mysqld]
> Change bind-address from 127.0.0.1 to 192.168.40.223.
> Add: server-id = 1
> Add: log-bin
> Add: binlog-do-db = test
> Add: binlog-ignore-db = mysql
2). Create a copy data account:
> Grant replication slave on *. * to 'slave _ Server' @ 192.168.40.225 identified by 'vobile ';
3) Restart mysql
>/Etc/init. d/mysql restart
3. Modify Slave (192.168.40.225)
1). Modify/etc/my. cnf
In [mysqld], make the following changes:
> Add: server-id = 2
> Add: master-host = 192.168.40.223
> Add: master-user = slave_server
> Add: master_password = vobile
> Master-port = 3306
2) Restart mysql
>/Etc/init. d/mysqld restart
4. Data Import
1) Export the test database in master (192.168.40.223): mysqldump-uroot test> test. SQL
2). Import test. SQL to the slave database:
> Mysql-uroot-e 'create database test ;'
> Mysql-uroot test <test. SQL
5. Enable slave
1). Input start slave in mysql on slave (192.168.40.255;
2). view the slave status (192.168.40.225 mysql): show slave status \ G;
> In the status values, Slave_IO_Running and Slave_ SQL _Running are set to Yes.
3). view the master status (192.168.40.223 mysql): show master status;
6. Detection results
1) In the master database, test has a table human with only three records, and three records are recorded in the same database and table in slave;
2) Insert a record in the master;
3). Add the same record to the corresponding slave.