6

我想知道是否可以在 phpMyAdmin 的登录屏幕上指定主机。

每当我需要连接到不同的服务器时,我都必须在config.inc.php.

4

2 回答 2

18

看看这个:

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++ 语句非常重要。服务器也可以来自不同的数据库类型。例如 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

使服务器列表显示在登录屏幕的漂亮下拉列表中的最后更改是 $cfg[''DisplayServersList''] = TRUE; 陈述。这样,每当您进入 phpmyadmin 的登录页面时,您都必须选择要使用的服务器。

于 2012-05-03T17:44:26.257 回答
1

在 PHPMyAdmin 的根目录下,您有一个名为config.sample.inc.php的文件。

将其重命名为config.inc.php并进行编辑!

搜索First server并在$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;
于 2015-05-06T00:11:57.270 回答