Cannot Grant select on mysql 8.0.17

允我心安 提交于 2021-02-10 14:35:27

问题


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): You are not allowed to create a user with GRANT

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.


回答1:


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.

Something like this:

1 - Create the role:

create ROLE name_of_your_role;

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 - Grant the role for your user:

grant 'name_of_your_role' to 'alice';

4 - Set this role as default to your user:

set default role 'name_of_your_role' to 'alice';


来源:https://stackoverflow.com/questions/57460201/cannot-grant-select-on-mysql-8-0-17

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!