天天看點

MySQL錯誤:ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES

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