加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

在phpMyAdmin中登录时是否可以指定主机?

发布时间:2020-12-13 22:41:13 所属栏目:PHP教程 来源:网络整理
导读:我想知道是否可以在phpMyAdmin的登录屏幕上指定主机. 每当我需要连接到不同的服务器时,我必须编辑config.inc.php中的主机字段. 看看这个: http://www.onlinehowto.net/config-multiple-servers-in-phpmyadmin/1405/* Single server config section */$i++;/
我想知道是否可以在phpMyAdmin的登录屏幕上指定主机.

每当我需要连接到不同的服务器时,我必须编辑config.inc.php中的主机字段.

看看这个:
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';

Above six lines of code configure PhpMyAdmin to connect to one server. Notice the i > variable that gets increased on the fist line $i++. To define another server just you need to copy paste the block above and change the hostname. It is very important to have the $i++ statement before each databases server configuration. The servers could also be from different database type. For example MySQL and PostgreSQL. This is why PhpMyAdmin is so popular and loved.

Here is working setup in one of the phpmyadmin instances that we manage

/*
* 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

The final change that will make the list of servers show in a nice dropdown list in the login scree is the $cfg[”DisplayServersList”] = TRUE; statement. This way any time you go to the login page of phpmyadmin you will have to select the server you want to work on.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读