What databases do I have permissions on
-
09-06-2019 - |
Question
How can I find what databases I have a minimum of read access to in either basic SQL, MySQL specific or in PHP?
Solution
There is a command in MySQL which can show you all of the permissions you have. The command is:
SHOW GRANTS;
It will give you output similar to:
root@(none)~> show grants; +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+ 1 row in set (0.00 sec)
This is documented at in the manual here.
OTHER TIPS
You could also try connecting to the database with phps mysql_connect(...) will tell you quickly whether or not you have access.
In MySQL, you can execute
SHOW DATABASES;
Description
SHOW DATABASES;
to see what you have at least minimal access to. Are you looking for something more programmatic?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow