Access denied for user 'root'@'%' to database 'ranger' ErrorCode: 1044

1、创建用户时报错

mysql> grant  select  on lon.* to 'dataddd'@'%' identified by 'Baaadi';
ERROR 1044 (42000): Access denied for user 'loan'@'%' to database 'lon'
mysql> 

以root用户登录mysql的,怎么还会遇到这问题
2、查看权限

mysql> SELECT host,user,authentication_string,Grant_priv,Super_priv FROM mysql.user;
+--------------+---------+-------------------------------------------+------------+------------+
| host         | user    | password                                  | Grant_priv | Super_priv |
+--------------+---------+-------------------------------------------+------------+------------+
| 192.168.28.% | oozie   | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | N          | Y          |
| 192.168.28.% | hive    | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | N          | Y          |
| 192.168.28.% | root    | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | Y          | Y          |
| localhost    | ranger  | *84BB87F6BF7F61703B24CE1C9AA9C0E3F2286900 | N          | N          |
| localhost    | root    | 0                                         | Y          | Y          |
| %            | root    | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | N          | Y          |
| 127.0.0.1    | root    | *FED29C14B2E900D70B11B1F1B370F953BA51A6A0 | Y          | Y          |
| %            | ranger  | *84BB87F6BF7F61703B24CE1C9AA9C0E3F2286900 | N          | Y          |
+--------------+---------+-------------------------------------------+------------+------------+
mysql> 
可以看到授权的权限没有打开,修复下
3、打开权限
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
 4、重新创建用户即可;

你可能感兴趣的:(mysql)