天天看點

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節,更加詳細的說明參見這裡:

<a href="http://dev.mysql.com/doc/refman/5.1/zh/replication.html#replication-options" target="_blank">http://dev.mysql.com/doc/refman/5.1/zh/replication.html#replication-options</a>

原因:是該權限(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.

SUPER權限同樣适用:

EOF.最後的一個連結:

<a href="http://www.osgeo.org/files/fdo/docs/FET_TheEssentialFDO/files/WS1a9193826455f5ff9110c71085341391d-2981.htm" target="_blank">http://www.osgeo.org/files/fdo/docs/FET_TheEssentialFDO/files/WS1a9193826455f5ff9110c71085341391d-2981.htm</a>

本文轉自 boy461205160 51CTO部落格,原文連結:http://blog.51cto.com/461205160/1748348