Hide specific databases in phpMyAdmin to users.

In a MySQL DB Hosting Environment, phpMyAdmin is a commonly used Web Frontend to give access to Customers to MySQL DB Administration.
In that scenario, it is common to hide specific databases to customer’s default Web-View.

The hide_db phpMyAdmin configuration option is a regular expression so useable to hide several databases (exclusion based on DB Name).

Simply open up phpMyAdmin’s config.inc.php configuration file and add a new line that looks like this:

$cfg['Servers'][$i]['hide_db'] = 'databases_regexp';

In the example, replace ‘databases_regexp’ has to be replaced with the regular expression to specify which databases to hide.
Note that inserting (for example) ‘mysql’ as the database (to hide the mysql database with all the permissions etc in it), any database with “mysql” in the name will be hidden, if there were any.

To hide just the mysql database:

$cfg['Servers'][$i]['hide_db'] = '^mysql$';

To hide the mysql and information_schema databases:

$cfg['Servers'][$i]['hide_db'] = '^information_schema|mysql$';

The ^ indicates the start of the string, the | means “boolean or” and the $ indicates the end of the string.


Comments are closed.