How to hide information_schema from being accessed from PHPMyAdmin

Posted on

Usually there is a certain requirement for databases so that it can be accessed using a web-based GUI such as PHPMyAdmin. It cannot allow information_schema to be presented after accessing it via web-based GUI presentation. Even using a normal user which is being granted only for dumping database purpose or even view access.

Normally, there are certain ways which is considered to solve the problem which in this context, it is hiding the information schema for being presented. But those steps or methods eventually doesn’t achieve the main purpose described in the title of this article. Below is the attempt of executing something ended in failure :

1. Try to remove all privileges for that user on information_schema

It can be achieved by executing the following command :

revoke all privileges on information_schema.* from 'user'@'host';
flush privileges;

2. Try to remove all privileges for that user for every entity in the database.

revoke all privileges on *.* from 'user'@'host';
flush privileges;

It can be achieved by executing the following command :

3. Try to grant specifically just for that user with the necessary privilege.

It can be achieved by executing the following command :

grant select, lock tables on database_name.* from 'user'@'host';

It seems all the effort done above is futile because the information_schema can still be viewed in PHPMyAdmin web interface. After searching for a better solution by googling it in Google search engine, there is an exception on PHPMyAdmin which is considered as a special treatment in order to hide the entity which is going to be selected. That is by adding a certain parameter in the config.inc.php file as shown below :

As far as I am concern, doing the installation by just extracting PHPMyAdmin from a compressed source file doesn’t give any default configuration file. Because it is given only as an example named ‘config.sample.inc.php’. So, copy the sample file configuration into a file named ‘config.inc.php’. After that, add the following line of configuration as shown below :

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

Just fill the value into a name of the entity which is going to be hidden. And in this context, it is the ‘information_schema’.

Leave a Reply