Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User with grant option can't grant create user

I created a user (new_user) with root like this:

GRANT ALL ON labor.* TO 'new_user'@'%' WITH GRANT OPTION;
GRANT ALL ON labor.* TO 'new_user'@'localhost' WITH GRANT OPTION;
GRANT CREATE USER ON *.* TO 'new_user'@'%';
GRANT CREATE USER ON *.* TO 'new_user'@'localhost';
GRANT RELOAD ON *.* TO 'new_user'@'localhost';
GRANT RELOAD ON *.* TO 'new_user'@'%'; 
FLUSH PRIVILEGES;

When I try to create another user the same way but with new_user, I get an access denied error. This error occurs after the GRANT ALL lines.

What else privilege should I add?

like image 465
thebator Avatar asked Sep 03 '13 12:09

thebator


People also ask

Are not allowed to create a user with Grant?

Starting with MySQL 8 you no longer can (implicitly) create a user using the GRANT command. Use CREATE USER instead, followed by the GRANT statement: mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'PASSWORD'; mysql> GRANT ALL PRIVILEGES ON *.

How do I give permission to grant a user in MySQL?

To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name. * TO 'username'@'localhost';

How do I create a user in MySQL 8.0 and grant all privileges?

Step 3 – Create a Database and User Next, create a user named testuser for localhost and set a password using the following command: CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'password'; We have created a testuser for localhost, which means testuser will be able to connect to MySQL only from the localhost.


1 Answers

The newly create user is missing the grant option on *.* (needed for grant create user on *.* ...)

GRANT GRANT OPTION ON *.* TO 'new_user'@'%';
GRANT GRANT OPTION ON *.* TO 'new_user'@'localhost';
like image 185
Xevelion Avatar answered Oct 17 '22 04:10

Xevelion