MySQL Permissions – Assign Permission to Count Tables Without Table Access

MySQLmysql-5.5permissions

As part of a script I am trying to count the number of tables that exist in a particular MySql schema.

Using my own user I am using the query

SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema = dbName 

However I'd like the user running this script to have as few permissions as possible, specifically I don't want them to have any select privileges on any of the tables belonging to the schema

Is it possible to assign a grant which would allow a user to count the number of tables without having any access to the tables themselves?

Best Answer

afaik, this is not possible. However, as an workaround you can create function which makes count(*) under required schema and grant execute on this function to user. User will not be able to access table, but will get required count.