根不能授予MySQL数据库的权限

我有一个MySQL数据库,我无法授权给新创build的数据库上的用户作为login时。

mysql> create database test1; Query OK, 1 row affected (0.00 sec) mysql> grant usage on *.* to 'test'@'%' identified by 'test'; ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: YES) mysql> show grants for root; +--------------------------------------------------------------------------------------------------------------+ | Grants for root@% | +--------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*hash_is_here' | +--------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select user(); +-----------------+ | user() | +-----------------+ | [email protected] | +-----------------+ 1 row in set (0.01 sec) 

所以如你所见,我可以以root身份login,root拥有所有的权限 。 任何想法如何发生这种情况? 我没有升级MySQL,同时保持数据(我知道这可能是由5升级到5.5)。 谢谢。

您拥有root @%的所有权限,但不具有“授权选项”的权限。 在MySql安装中,我的root帐户可以应用grant,这是“show grants”的输出:

授予所有特权 TO'root'@'%'IDENTIFIED BY密码'some_hash'WITH GRANT OPTION

在MySql中,给予“所有权限”不包括授予。 必须明确给出。

即使你不在5.5,也许你仍然需要从MySQL / bin目录运行mysql_upgrade?

在这里看到第一个答案:

https://stackoverflow.com/questions/8484722/access-denied-for-user-rootlocalhost-while-attempting-to-grant-privileges