用以下命令即可
mysql> start slave;
Query OK, 0 rows affected (0.01 sec) --read-only选项
mysql> grant all privileges on test1.* to [url=]'z1'@'%'[/url] identified by '1234';
Query OK, 0 rows affected (0.01 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) mysql> select * from db where user='z1' \G;
*************************** 1. row ***************************
Host: %
Db: test1
User: z1
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Execute_priv: Y
Event_priv: Y
Trigger_priv: Y
1 row in set (0.00 sec)
[root@slave38 mysql]# mysql -uz1 -p1234
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.41-log MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test1 |
+--------------------+
mysql> select * from t1;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
+------+
3 rows in set (0.00 sec) mysql> insert into t1 values(4),(5);
ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement
-------------
选项replicate-do-db,replicate-do-table等,以下以replicate-do-table为例
只更新 test1.t1表
[root@slave38 mysql]# mysqld_safe --replicate-do-table=test1.t1 &
主服务器上
mysql> insert into t1 values(10),(20);
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0 mysql> insert into t2 values(1,'xiaofeng'),(2,'azhu');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from t2;
+------+----------+
| id | name |
+------+----------+
| 1 | xiaofeng |
| 2 | azhu |
+------+----------+
2 rows in set (0.00 sec) mysql> select * from t1;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 10 |
| 20 |
+------+
5 rows in set (0.00 sec) mysql> select * from t2;
Empty set (0.00 sec)
选项slave-skip-errors