问题
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