我想知道是否可以在phpMyAdmin的登录屏幕上指定主机。
每当我需要连接到不同的服务器时,我必须在config.inc.php
中编辑主机字段。
答案 0 :(得分:16)
看看这个:
http://www.onlinehowto.net/config-multiple-servers-in-phpmyadmin/1405
/* Single server config section */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'dbsub';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
以上六行代码配置PhpMyAdmin连接到一台服务器。注意i>在第i行$ i ++上增加的变量。要定义另一台服务器,只需复制粘贴上面的块并更改主机名即可。在每个数据库服务器配置之前使用$ i ++语句非常重要。服务器也可以来自不同的数据库类型。例如MySQL和PostgreSQL。这就是PhpMyAdmin如此受欢迎和喜爱的原因。
以下是我们管理的一个phpmyadmin实例中的工作设置
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'db';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/*
* Second server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'dbsub';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/*
* Third server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'stats1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['DisplayServersList'] = TRUE;
/*
* End of servers configuration
将使登录scree中一个漂亮的下拉列表中显示的服务器列表的最终更改是$ cfg [''DisplayServersList''] = TRUE;声明。这样,只要你进入phpmyadmin的登录页面,你就必须选择你想要使用的服务器。
答案 1 :(得分:1)
在PHPMyAdmin的根目录下,您有一个名为 config.sample.inc.php 的文件。
将其重命名为 config.inc.php 并进行编辑!
搜索第一台服务器并在 $ cfg ['Servers'] [$ i] ['host'] 设置正确的值。
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '192.168.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;