MySQL错误:ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
在执行MySQL复制的前奏时:为主服务器创建用户以便从服务器连接,出现该错误:
GRANT REPLICATION SLAVE ON a_database.* to 'repl'@'domain.test' IDENTIFIED BY 'slavepass';
之所以指定数据库我是希望能只复制这个数据库而忽略其他(已创建的或今后会创建的)数据库。
因为我还不知道MySQL可以在配置文件(/etc/my.cnf)中(或启动时指定该参数)有一个专门的参数来指定数据库:--replicate-do-db=数据库名
引用:告诉从服务器限制默认数据库(由USE所选择)为db_name的语句的复制。要指定多个数据库,应多次使用该选项,每个数据库使用一次。
来自MySQL5.1 manual 6.8节,更加详细的说明参见这里:
http://dev.mysql.com/doc/refman/5.1/zh/replication.html#replication-options

参考:http://forums.mysql.com/read.php?26,47781,47828#msg-47828

官方论坛上这个问题的主题:http://forums.mysql.com/read.php?26,47781,47781
还有:http://forums.admon.org/databases/6970-error-1221-hy000-incorrect-usage-db-grant-global-privileges.html

原因:是该权限(REPLICATION SLAVE)是一个全局权限(Global privilege),不能单独指定给数据库级别(database level)。
比如,FILE权限不能授予给database level:
引用:It complains about that you are trying to use FILE privilege on a database level. And that is a Global privilege.
见:
http://forums.devshed.com/mysql-help-4/error-1221-wrong-usage-of-db-grant-and-global-privileges-110852.html

SUPER权限同样适用:
见:
http://webcache.googleusercontent.com/search?q=cache:http://systemadmin.es/2011/10/incorrect-usage-of-db-grant-and-global-privileges

EOF.最后的一个链接:
http://www.osgeo.org/files/fdo/docs/FET_TheEssentialFDO/files/WS1a9193826455f5ff9110c71085341391d-2981.htm