A recent project update involved adding a massive amount of relatively (updates every 6-12 months) static data for the application. Because of its size (appx 1GB, including indexing), it was elected to include it in a separate database. The code has been updated to handle it all already, but now what was an easy one-off on the development machines would be a rather large headache to deploy with the update: namely, to add the application's user privileges to the new database.
Is there an easy way to copy the user that already exists on the main database to have access to the new one?
e.g. The user was originally created with the standard "GRANT ALL on main_db.* to user@localhost identified by 'XX';"
And I'm hoping to find a way to easily turn that into "GRANT ALL on static_db.* to user@localhost identified by 'XX';" without having to manually do it on every server the application is deployed on (and yes, they all have different values for "XX". :) )
Edit: Using Devart's advice as as starting point, I got what I needed. The table in question for database-wide permissions is mysql.db. Posting the query here (in generic form) in case it helps anyone else.
INSERT INTO mysql.db
SELECT
Host, 'New_DB', User, Select_priv, Insert_priv, Update_priv, Delete_priv,
Create_priv, Drop_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
Create_tmp_table_priv, Lock_tables_priv, Create_view_priv, Show_view_priv,
Create_routine_priv, Alter_routine_priv, Execute_priv, Event_priv, Trigger_priv
FROM mysql.db
WHERE
User='username' AND Host = 'hostname' AND Db='Old_Db';