I have a database where I would like users to be able to create new users. That is achievable via GRANT CREATE USER as follows:
grant create user on *.* to foo;
This works great and foo can create users. My problem is that the line above works if run as root, but does not work if run as a normal user, even if such user already has the CREATE USER privilege.
In short, normal users cannot delegate the ability to create users. I have been searching far and wide for any particular privilege you need to be able to do this, and I'm beginning to think it's something that only root can do, although I have found no evidence of this in the MySQL documentation.
The question: how can I allow a normal user to let new users create users?
Both answers were useful - I used a combination of both and it seems to have worked.
As root (admin is a normal user):
mysql> grant create user on *.* to admin with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
As admin (remember, he's a normal user):
mysql> grant create user on *.* to foo with grant option;
Query OK, 0 rows affected (0.00 sec)
Thank you so much.
-- Create username user
GRANT ALL PRIVILEGES ON `tshirtshop`.*
TO 'username'@'localhost' IDENTIFIED BY 'password'
WITH GRANT OPTION;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With