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 7435225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:02:11+00:00 2026-05-29T10:02:11+00:00

I have discovered a difference between show grants for user@host and the mysql.db table.

  • 0

I have discovered a difference between show grants for user@host and the mysql.db table. Why is this?

How can I resolve this? We are worried about security.

I ran a show grants against users in mysql.users. In mysql.users the user is user@xxx.xxx.xxx.xx and when I run show grants it says GRANT USAGE TO user@xxx.xxx.xxx.xx

This worried me as this user also seems to be able to access a database.

When I looked in mysql.db and information_schema.schema_privileges I can see the same user as user with a host of xxx.xxx.% with full access to that database.

What gives?

Edit – Deeper Explanation:

Here is what I have:

show grants for 'myuser'@'xxx.xxx.xxx.xxx';

It returns:

GRANT USAGE ON *.* TO 'myuser'@'xxx.xxx.xxx.xxx' IDENTIFIED BY PASSWORD 'xxxxxxxxxxxxxxxxx'

If I run:

select host,db,user from mysql.db where user='myuser';

I get:

+----------+------------+------------+
| host     | db         | user       |
+----------+------------+------------+
|xxx.xxx.% | somedb     | myuser     |
+----------+------------+------------+
  • 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-29T10:02:12+00:00Added an answer on May 29, 2026 at 10:02 am

    Don’t worry.

    The mysql.user table mitigates specific global privileges on all databases.

    If a user is restricted to a specific database, you will only see database specific grants in the mysql.db table. A user restricted to a database does not need SUPER, PROCESS, SHUTDOWN, and privileges like these.

    If you create a user withglobal privileges (thus landing the user in mysql.user), you cannot revoke global privileges only to demote the user to a specfic database. If you try to do so with REVOKE commands, you will see the user in mysql.user with the original Y values on all columns and the same user in mysql.db with Y values on database specific privileges.

    You must completely drop the user and create the user fresh with the lower privileges.

    Here is an example based on the comments

    mysql> show grants for advdb@'%';
    +-----------------------------------------------------------------------------+
    | Grants for advdb@%                                                          |
    +-----------------------------------------------------------------------------+
    | GRANT USAGE ON *.* TO 'advdb'@'%' IDENTIFIED BY PASSWORD '................' |
    | GRANT ALL PRIVILEGES ON `advertpro`.* TO 'advdb'@'%'                        |
    +-----------------------------------------------------------------------------+
    

    The GRANT USAGE simply allows you to know what MD5 password is involved with authentication (if the password is not blank). Note that advdb can login from any IP address and only access the advertpro database.

    The user does not need PROCESS privilege unless you want the user to see all processes in the processlist, even the one that belong to others.

    The user does not need SUPER privilege unless you want the user to write in a read-only mysql instance, start and stop replication, zap binary logs, and things like these.

    The user does not need SHUTDOWN privilege unless you want the user to shutdown mysql from the OS command line user the mysqladmin client program.

    To copy the priv you are looking for,

    • SHOW GRANTS FOR 'user'@'xxx.xxx.xxx.%';
    • Copy the output to text file
    • Edit the host to xxx.xxx.xxx.xx
    • Add a semicolon
    • Paste that to the other server

    OK let’s hack that:

    UPDATE mysql.db
        SET host='xxx.xxx.xxx.xxx'
        WHERE user='myuser'
        AND host='xxx.xxx.%'
        AND db='somedb';
    FLUSH PRIVILEGES;
    

    This should it !!!

    To dump the MySQL Grants in SQL, you can do pt-show-grants
    It is much better to port the mysql grants using pt-show-grants.

    Here is my personal emulation of what pt-show-grants does

    mysql -hhostaddr -umyuserid -pmypassword --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql -hhostaddr -umyuserid -pmypassword --skip-column-names -A | sed 's/$/;/g' > MySQLUserGrants.sql
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just recently discovered the difference between different constructors in GDI+. Going: var
I just have discovered the fundamental difference between two input forms for floating-point numbers:
Does the code below smell? I'm refactoring some code and have discovered this circular
I am new to LINQ and discovered yesterday that you can have multiple where
I have discovered through trial and error that the MATLAB engine function is not
We have discovered that one of our auto generated assemblies is throwing a StackOverflowException
Recently I have discovered that my release executable (made with msvc++ express 2008) becomes
My testers have discovered that if you type free text into a file upload
While debugging an issue with our system, I have discovered a thread contention that
As well as my question Removing MKMapView Annotations causes leaks. I have discovered that

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.