config.inc.php (位於 phpMyAdmin 根目錄)。若不存在,複製 config.sample.inc.php 重命名。
config)取消自動登錄 (恢復
cookie模式)$cfg['Servers'][$i]['auth_type'] = 'cookie'; // 預設模式,顯示登錄頁面 // 註釋或刪除 user/password 行 // $cfg['Servers'][$i]['user'] = 'root'; // $cfg['Servers'][$i]['password'] = 'your_password';認證模式對比
| 模式 | auth_type 值 | 特點 | 適用場景 |
|---|---|---|---|
| 配置文件認證 | config | 無需登錄頁,直接進入;密碼明文存配置文件 | **僅限本地開發/受信任內網**,極大安全風險 |
| Cookie 認證 | cookie | 顯示登錄頁,密碼加密存 Cookie (blowfish_secret 需設置) | **生產環境標準**,多用戶共享 phpMyAdmin |
| HTTP 認證 | http | 瀏覽器原生彈窗認證,依賴 Web Server (Apache/Nginx) 模塊 | 配合 Web Server 認證體系 (如 .htaccess) |
| Signon 認證 | signon | 單點登錄 (SSO) 集成,需實現 signon_session 接口 | 企業內部系統集成 |
// 必須設置,用於 Cookie 加密 (32 字符隨機字符串) $cfg['blowfish_secret'] = 'your_32_chars_random_string_here'; // 強制 SSL (如果支持) $cfg['ForceSSL'] = true; // 禁止無密碼登錄 $cfg['Servers'][$i]['AllowNoPassword'] = false; // 限制登錄嘗試次數 (防暴力破解) $cfg['LoginCookieValidity'] = 1440; // Cookie 有效期 1440 秒 (24 分鐘) $cfg['LoginCookieStore'] = 0; // 瀏覽器關閉即失效
config.inc.php (而非 sample)。session.save_path 目錄可寫,blowfish_secret 已設置且長度足夠。GRANT ...)。config 模式圖方便,**務必限制只允許本機訪問 (防火牆/bind-address)**。cookie 模式**,設置強 blowfish_secret,配合 Web Server 訪問控制 (IP 白名單/VPN/基本認證)。auth_type 並增減 user/password 配置,保存即時生效。