mysql grant命令错误:ERROR 1044 (42000): Access denied for 'root' With All Privileges

http://stackoverflow.com/questions/21714869/error-1044-42000-access-denied-for-root-with-all-privileges

 

首先,确认当前的登录用户:

select user();
select current_user();

第一条命令返回试图登录的用户;第二条命令返回实际链接的用户。

确认是否以 root@localhost 登录。

 

root@localhost已被赋予的权限Grant_priv。

查看已有的权限:

mysql> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;
+-----------+------------------+-------------------------------------------+------------+------------+
| host      | user             | password                                  | Grant_priv | Super_priv |
+-----------+------------------+-------------------------------------------+------------+------------+
| localhost | root             | ***************************************** | N          | Y          |
| localhost | debian-sys-maint | ***************************************** | Y          | Y          |
| localhost | staging          | ***************************************** | N          | N          |
+-----------+------------------+-------------------------------------------+------------+------------+

可以看到 root@localhost的Grant_priv是N,应该设为Y:

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
GRANT ALL ON *.* TO 'root'@'localhost';

重新登录,问题解决。

posted @ 2015-05-29 16:05 泉水叮~咚 阅读(...) 评论(...) 编辑 收藏