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

升级phpMyAdmin后如何移除登录选项中的localhost

解决phpMyAdmin登录下拉框出现localhost选项的问题

问题原因

新版phpMyAdmin会默认填充localhost作为索引为0的服务器,当你的配置中跳过了索引0(比如初始$i=0后直接$i++,导致索引0未配置),系统就会自动生成这个默认的localhost选项。

解决方案

方法1:修正服务器索引,从0开始配置

修改你的config.inc.php,删除那个空的“First server”配置段,直接从索引0开始配置实际服务器:

declare(strict_types=1);

$cfg['blowfish_secret'] = 'notshown';

/**
 * Servers configuration
 */
$i = 0;

/* Server: sqlname [1] */
$cfg['Servers'][$i]['verbose'] = 'sqlname';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'private ip';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['UploadDir'] = '/foldername';
$cfg['SaveDir'] = '/foldername/';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

$i++;

/* Server: sqlname [2] */
$cfg['Servers'][$i]['verbose'] = 'sqlname';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'private ip';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['UploadDir'] = '/foldername';
$cfg['SaveDir'] = '/foldername/';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

方法2:指定默认服务器并禁用空索引

如果你不想调整现有服务器索引,可添加$cfg['DefaultServer']指定一个已配置的服务器索引(比如你的实际服务器索引是2或3),同时明确设置索引0的服务器参数为空:

// 在服务器配置段前添加
$cfg['DefaultServer'] = 2; // 替换为你的实际服务器索引

// 配置索引0为空
$i = 0;
$cfg['Servers'][$i]['host'] = '';
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['auth_type'] = 'cookie';

// 继续配置你的实际服务器
$i++;
// ... 以下保留原实际服务器配置

验证修改

保存config.inc.php后,刷新phpMyAdmin登录页面,localhost选项应该会消失,仅显示你配置的服务器。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 16:35:03