返回列表 回復 發帖

讓information_schema資料庫在 PHPMyAdmin中不顯示

讓information_schema資料庫在 PHPMyAdmin中不顯示在預設的情況下,安裝完phpMyAdmin後,不管用什麼帳號登入,一定都會看到 information_schema 這個資料庫,但我們又不能對這個資料庫進行修改,只能查看它的一些訊息,大家都想把這個資料庫隱藏起來不要顯示,其實phpMyAdmin提供這項功能。
找到根目錄下的config.inc.php檔,然後在大約第35行的位置
在下圖第7行的位置 $cfg['Servers'][$i]['extension'] = ‘mysql’; 這行底下
加入這行 $cfg['Servers'][$i]['hide_db'] = ‘information_schema’;
如下:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$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';
  
$cfg['Servers'][$i]['hide_db'] = 'information_schema';
  
/* User for advanced features */
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Advanced phpMyAdmin features */
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';



這樣它就會把 information_schema資料庫隱藏不要出現了
OK,大功告成
填完後再重新登入到phpMyAdmin,您會發現這個資料庫就不會再顯示了。


Then add a new line that looks like this:


1$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:


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



To hide the mysql and information_schema databases you would do this:

1$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.:


1$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.
返回列表 回復 發帖