mysql 主从复制报错 :Incorrect usage of DB GRANT and GLOBAL PRIVILEGES

在配置 mysql 主从复制时,想通过grant replication slave on test_repl.* to 'test_repl'@'192.168.3.5' identified by '123456';来限制主从复制只作用于 test_repl 数据库,但是上面的语句会报错:Incorrect usage of DB GRANT and GLOBAL PRIVILEGES 因为 replication slave 的级别是 global,所以不能只作用于某一数据库,而是全局。

所以还是要通过 grant replication slave on *.* to 'test_repl'@'192.168.3.5' identified by '123456'; 并在 /etc/my.cnf 中添加 binlog-do-db=test_repl 来限制主从复制的数据库为 test_repl。

08-13 10:09