How to hide information_schema database from phpmy

2020-05-20 10:00发布

问题:

I am able to hide the database from writing this line

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

in config.inc.php file pf phpmyadmin.

It is possible to access content of this database through url like http://www.test.com/phpmyadmin/index.php?db=information_schema&token=3ba37ae1e41f6a10e4afc7c69b934bba

How is it possible to remove complete access of information_schema database ?

回答1:

You can even hide multiple DBs using pipe separator

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


回答2:

I installed phpmyadmin in outside directory but and these methods didn't work for me.

Open phpmyadmin

Settings > Features > General > database > Hide databases

Enter Database that you want to hide as following

information_schema|performance_schema|mysql


回答3:

In case you also want to restrict users from accessing the information_schema from a url like you posted and you are not satisfied with hide_db configuration directive then you may add the following line in config.inc.php file of phpmyadmin.

if($_GET['db'] == 'information_schema')exit;


回答4:

I'd write this comment on the highest upvoted answer, but I don't have enough reputation yet.

When specifying multiple databases, keep in mind it operates under RegEx rules (as the help states). So while it may be unlikely, putting "information_schema|performance_schema|mysql" will also hide any DB's that contain these strings.

Instead, put "^information_schema|performance_schema|mysql$". In regular expressions, ^ denotes the beginning of the string, and $ denotes the end.

This means you can also hide databases by partial string. While you should always control database access by MySQL user permissions, you can hide groups of DB's using partial matching. For example if you didn't want all your test databases visible, you could put "^test_" in the hidden databases field and it will hide all databases that start with test_. EG test_123, test_456.