A few days ago I posted how to hide the information schema in phpMyAdmin and of course using the advice in that post you can hide any database you want. The hide_db phpMyAdmin configuration option is a regular expression so you can use it to hide several databases, and this post looks at how to do this.
$cfg[‘Servers’][$i][‘hide_db’] option with multiple databases
Open up phpMyAdmin’s config.inc.php configuration file in your favourite text editor and look for the following section:
/* * First server */ $i++; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* Server parameters */ $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; /* Select mysqli if your server has it */ $cfg['Servers'][$i]['extension'] = 'mysql'; /* User for advanced features */ $cfg['Servers'][$i]['controluser'] = ''; $cfg['Servers'][$i]['controlpass'] = '';
Then add a new line that looks like this:
$cfg['Servers'][$i]['hide_db'] = 'databases go here';
In the above example, replace ‘databases go here’ with the regular expression to specify which databases you want to hide. Note that if you simply put something like "mysql" as the database (to hide the mysql database with all the permissions etc in it) then any database with "mysql" in the name will be hidden, if there were any.
Therefore to hide just the mysql database, you would do this:
$cfg['Servers'][$i]['hide_db'] = '^mysql$';
To hide the mysql and information_schema databases you would do this:
$cfg['Servers'][$i]['hide_db'] = '^(information_schema|mysql)$';
The ^ indicates the start of the string, the | means "or" and the $ indicates the end of the string. So each additional database you add would have | then the database name, e.g.:
$cfg['Servers'][$i]['hide_db'] = '^(information_schema|mysql|foo)$';
Please note that this will hide the databases from the user, but it doesn’t stop them from being able to run queries against tables you have hidden. You would need to modify the MySQL database permissions to prevent them access to particular databases. Note also that when you do limit the databases a user has access to, phpMyAdmin won’t show them in the list of databases.