views:

190

answers:

3

How can I find what databases I have a minimum of read access to in either basic SQL, MySQL specific or in PHP?

+1  A: 

In MySQL, you can execute SHOW DATABASES; and SHOW TABLES; to see what you have at least minimal access to. Are you looking for something more programmatic?

Jay Shepherd
+4  A: 

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.

Harrison Fisk
+1  A: 

You could also try connecting to the database with phps mysql_connect(...) will tell you quickly whether or not you have access.

SeanJA
That would only show weather or not I can connect to the database server with the given username and password, it will not show weather or not the user has write permissions on a specific database.
Unkwntech