1

I am making a website that I expect to be hosted on several servers. I want to be able to check to make sure the MySQL user that has been created on those servers has sufficient privileges so that I can give a clear error if one of the privileges that the MySQL user requires is missing.
I found the MySQL command SHOW GRANTS FOR CURRENT_USER but its output looks like it would require a bunch of work to parse.

Is there a better way to verify that the MySQL user has sufficient permissions?

1
  • Doesn't necessarily need to be in PHP. If there is a good solution with MySQL that is fine too, just not in Perl or Python or something preferably. Commented Feb 14, 2014 at 3:45

1 Answer 1

1

Hi try using the select statement below instead of SHOW GRANTS.

SELECT * FROM mysql.user WHERE USER LIKE 'root';
Sign up to request clarification or add additional context in comments.

3 Comments

this can be done if the user has an access to the mysql database.
Sorry, is it possible to get privilege information like that but just for one table as that command does not give any info about database level privileges
there's multiple tables in mysql.* that contain the global-, db-, and user-level privileges. you'll have to query them all to see what a user's REALLY got granted to them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.