Alle tildelte rettigheder gemmes i systemtabeller, f.eks. - mysql.tables_priv, mysql.columns_priv, mysql.db... Du kan skrive et script for at kopiere alle de privilegier, du har brug for.
Antag, at vi har bruger -
CREATE USER 'user1'@'%';
GRANT Insert ON TABLE database1.table1 TO 'user1'@'%';
GRANT Execute ON PROCEDURE database1.procedure1 TO 'user1'@'%';
Nu vil vi kopiere disse privilegier for at få adgang til databasen 'database2' -
-- Copy table's privileges
INSERT INTO mysql.tables_priv SELECT host, 'database2', user, table_name, grantor, timestamp, table_priv, column_priv FROM mysql.tables_priv
WHERE user = 'user1' AND host = '%' AND db = 'database1';
-- Copy routine's privileges
INSERT INTO mysql.procs_priv SELECT host, 'database2', user, routine_name, routine_type, grantor, proc_priv, timestamp FROM mysql.procs_priv
WHERE user = 'user1' AND host = '%' AND db = 'database1';
-- Do not forget to apply changes ;-)
FLUSH PRIVILEGES;
Gør det samme for andre systemtabeller.