I am working on a complex site development that utilizes multiple databases. Basically, for each Web form I develop on the site, I need to have a separate database to collect the results. However, there is some information that should remain consistent across all of my Web forms.
I would like to keep that information in a single database.
However, in order to make things a little easier, I would like to find some way to automatically grant SELECT privileges on the specific shared database/tables whenever a new user is created (as I am creating a new user for each database I create, in order to keep one form database user from being able to alter anything in another form database).
Is there any way to write a stored procedure or function to automatically execute the following queries whenever a new user is created?
PHP Code:
GRANT SELECT ON `dbname`.`tablename` TO [specifieduser]@`localhost`
GRANT SELECT ON `dbname`.`table2` TO [specifieduser]@`localhost`
In the case of this query, "specifieduser" is a variable that should be automatically filled in when the user is created.
Any thoughts?
I am running MySQL 5.0.51a, in case that helps. Thank you.