We have several databases with the same structure running on our MySQL server. Now we need an user which requires INSERT privileges on all databases, but on a specific table.
Is it possible?
I tried the grant below, but no luck:
grant INSERT on *.mytable to 'myuser'@'%'
As you can see, I'm trying to avoid the creation of one user per database. If the approach above is not possible, is there any other way to achieve this goal?
I know that the opposite is possible (create an user which has privileges on all tables of a given database or all tables in all databases). I can achieve it by doing:
grant on dbname.* to 'myuser'@'%'
grant on *.* to 'myuser'@'%'
The global privileges are described here: http://dev.mysql.com/doc/refman/5.1/en/grant.html#grant-global-privileges, but I couldn't find such option there.
You may have to hack it using mysql schema tables to make the grants you need:
First of all, here is the description of mysql.tables_priv
You may have to gather all the databases that have mytable and append the string '.mytable'
Then, take that list and create the proper grant for that list of tables for each specific user
You should take that query and export it to a text file called /root/GlobalTableGrants.sql
Now just login to mysql run that script
After you run the script, do this
You should see every occurrence of my_table with table level privs enabled.
Give it a Try !!!