无法在 mysql 8.0.17 上授予选择权 [英] Cannot Grant select on mysql 8.0.17

查看:49
本文介绍了无法在 mysql 8.0.17 上授予选择权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为每个主机的用户授予选择权限,但出现错误,您不允许创建用户

I want to grant select privilege to user from every host, but getting an error, you're not allow to create a user

mysql>GRANT SELECT ON *.* TO 'alice'@'%' WITH GRANT OPTION;

ERROR 1410 (42000):您不能使用 GRANT 创建用户

ERROR 1410 (42000): You are not allowed to create a user with GRANT

我不想创建新用户,为此我使用了命令 CREATE USER

I don't want to create a new user, for that I used command CREATE USER

我尝试创建一个新用户,但授权命令也失败了.

I tried to create a new user but the grant command also failed.

推荐答案

在这个 MySql 版本(8 及以上)中的一个好主意(和一个好实践)是配置 ROLES,然后为其设置用户,像这样 好文章(阅读它,非常好!).

A good idea (and a good practice) in this MySql Version (8 and above) is to config ROLES and then set the users for it, like this good article (read it, is very good!).

您可以将您的角色设置为多个用户.

You'll can set your role to many users.

像这样:

1 - 创建角色:

create ROLE name_of_your_role;

2 - 为 ROLE 设置必要的权限,记住,在这个 MySql 版本中你不需要刷新权限.示例(更改 mydatabase 表达式 为您的数据库名称或通配符,如您所需要):

2 - Set the necessary privileges to the ROLE, and remember, in this MySql version you dont need of Flush Privileges. Example (change mydatabase expression for your database name or wildcard, like you need):

grant alter,create,delete,drop,index,insert,select,update,trigger,alter
 routine,create routine, execute, create temporary tables 
on mydatabase.* to 'name_of_your_role';

3 - 为您的用户授予角色:

3 - Grant the role for your user:

grant 'name_of_your_role' to 'alice';

4 - 将此角色设置为您的用户的默认角色:

4 - Set this role as default to your user:

set default role 'name_of_your_role' to 'alice';

这篇关于无法在 mysql 8.0.17 上授予选择权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆