实现步骤:
1、打开“路径/phpmyadmin/config.inc.php”,查找相关项并修改为以下内容:
在$i++下面添加
$cfg['Servers'][$i]['host'] = '192.168.10.100';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'php520';
$cfg['Servers'][$i]['port'] = '';
2、打开“路径/phpmyadmin/index.php”,在文件最开头增加以下PHP代码:
if(@$_POST["mysqlhost"] != "" && @$_POST["mysqlport"] != "")
{
setcookie("mysqlhost", @$_POST["mysqlhost"]);
setcookie("mysqlport", @$_POST["mysqlport"]);
}
3、打开“路径/phpmyadmin/libraries/auth/cookie.auth.lib.php”,查找“name="pma_servername"”这行,在该行下方的第3行后(即“<?php } ?>”这行后)增加以下HTML代码:
<div class="item">
<label for="input_username">服务器地址:</label>
<input type="text" name="mysqlhost" id="mysqlhost" value="<?=$_COOKIE["mysqlhost"];?>" size="24" class="textfield" />
</div>
<div class="item">
<label for="input_username">MySQL端口:</label>
<input type="text" name="mysqlport" id="mysqlport" value="<?=$_COOKIE["mysqlport"];?>" size="24" class="textfield" />
</div>
4、打开“路径/phpmyadmin/libraries/config.default.php”,查找相关项并修改为以下内容:
- $cfg['Servers'][$i]['host'] = $_COOKIE["mysqlhost"];
- $cfg['Servers'][$i]['port'] = $_COOKIE["mysqlport"];
- $cfg['Servers'][$i]['auth_type'] = 'cookie';
修改完毕,清除浏览器重新登录即可。