Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allowing a MySQL user to grant themselves privileges to a new database

I have a MySQL user, which we'll call Tom. Tom has global CREATE and SHOW DATABASES privileges, with the 'GRANT' option. The user is assigned SELECT, INSERT, UPDATE and DELETE privileges on a per-database basis. However, after Tom creates a new database, he can't set his SELECT etc. privileges, despite having a global GRANT option. The error is (predictably) :

CREATE DATABASE `my_new_db`; -- this is fine
GRANT SELECT , INSERT , UPDATE , DELETE ON `my_new_db` . * TO 'Tom'@'%';
*Access denied for user 'Tom'@'%' to database 'my_new_db'*

This is being done via PHP, but I doubt that makes much difference.

Someone tell me what I'm doing wrong! Ta =]

like image 918
Grim... Avatar asked Oct 10 '22 06:10

Grim...


1 Answers

You can't grant privileges you don't have. Tom needs to have global SELECT, INSERT, UPDATE, and DELETE privileges in order to grant them to others.

like image 73
kbolino Avatar answered Oct 14 '22 01:10

kbolino