Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6549323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:04:45+00:00 2026-05-25T12:04:45+00:00

A recent project update involved adding a massive amount of relatively (updates every 6-12

  • 0

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';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:04:45+00:00Added an answer on May 25, 2026 at 12:04 pm

    All granted privileges are stored in system tables, e.g. – mysql.tables_priv, mysql.columns_priv, mysql.db… You can write a script to copy all privileges you need.

    Suppose we have user –

    CREATE USER 'user1'@'%';
    GRANT Insert ON TABLE database1.table1 TO 'user1'@'%';
    GRANT Execute ON PROCEDURE database1.procedure1 TO 'user1'@'%';
    

    Now, we will copy these privileges to have access to database ‘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;
    

    Do the same for another system tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On a recent Java project, we needed a free Java based real-time data plotting
A recent project called for importing data into an Oracle database. The program that
In a recent project, I built my own MVC framework in PHP. One of
In a recent project I have nearly completed we used an architecture that as
Whilst working on a recent project, I was visited by a customer QA representitive,
In a recent project the lead developer designed a database schema where larger tables
There is another recent Project Euler question but I think this is a bit
On a recent project I have been working on in C#/ASP.NET I have some
for a recent project I need to detect file system changes on a mapped
in a recent project I've come really need the lib tre matching library. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.