You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

phpMyAdmin登录页无法显示多服务器下拉选择框如何解决

phpMyAdmin多服务器选择配置修复方案

核心问题原因

你当前的配置存在3个关键错误,导致多服务器列表无法正常显示:

  • 第二台Docker服务器的地址配置错误,不能将端口直接拼接在host字段后,需要分开配置host和port参数,地址格式错误会导致phpMyAdmin加载服务器配置时报错,出现空白页
  • 第一台服务器配置执行完成后必须递增$i变量,否则第二台的配置会直接覆盖第一台的同下标配置项,导致仅显示单台服务器
  • 第二台服务器缺少必填的extension扩展配置,未指定使用mysqli扩展,会导致连接逻辑异常

修正后的完整配置

首先确保配置文件开头已初始化$i变量(默认phpMyAdmin配置自带,缺失的话请在最上方添加$i = 1;),然后按如下修改对应代码段:

if (!empty($dbname)) {
    /* Authentication type */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['verbose'] = 'db on the pc'; //provide hostname and port if other than default
    /* Server parameters */
    if (empty($dbserver)) $dbserver = 'localhost';
    $cfg['Servers'][$i]['host'] = $dbserver;

    if (!empty($dbport) || $dbserver != 'localhost') {
        $cfg['Servers'][$i]['connect_type'] = 'tcp';
        $cfg['Servers'][$i]['port'] = $dbport;
    }
    //$cfg['Servers'][$i]['compress'] = false;
    /* Select mysqli if your server has it */
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    /* Optional: User for advanced features */
    $cfg['Servers'][$i]['controluser'] = $dbuser;
    $cfg['Servers'][$i]['controlpass'] = $dbpass;
    /* Optional: Advanced phpMyAdmin features */
    $cfg['Servers'][$i]['pmadb'] = $dbname;
    $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]['table_uiprefs'] = 'pma__table_uiprefs';
    $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
    $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
    $cfg['Servers'][$i]['recent'] = 'pma__recent';
    $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
    $cfg['Servers'][$i]['users'] = 'pma__users';
    $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
    $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
    $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
    $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
    $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
    $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

    /* Uncomment the following to enable logging in to passwordless accounts,
     * after taking note of the associated security risks. */
    // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

    /* Advance to next server for rest of config */
    $i++;
}

// 放开此处的$i递增注释
$i++;
// 第二台服务器配置修正
$cfg['Servers'][$i]['verbose'] = 'second_db';
$cfg['Servers'][$i]['host'] = '172.18.0.1';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['user'] = 'user';
$cfg['Servers'][$i]['password'] = 'pass';
$cfg['Servers'][$i]['auth_type'] = 'config';

// 强制开启登录页服务器选择下拉框(可选,默认自动开启,配置异常时可强制显示)
$cfg['ShowServerChoice'] = true;

验证方法

修改保存配置文件后,清除浏览器缓存,重新访问phpmyadmin.test,登录页即可看到服务器下拉选择框,两台服务器会分别显示db on the pc和second_db的选项。

注:如果你不需要预存Docker服务器的账号密码,可将第二台的auth_type改为cookie,即可在登录时手动输入账号密码,安全性更高。

内容的提问来源于stack exchange,提问作者dan178

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 04:15:03