針對 phpMyAdmin 2.11.5 版本(較舊,現行建議用 5.x),記錄配置關鍵步驟,原理同適用於新版。
phpMyAdmin-2.11.5.tar.gz,解壓至 Web 根目錄。phpmyadmin(或自訂名稱,避免預設名稱被掃描)。libraries/config.default.php注意:新版建議複製 config.sample.inc.php 為 config.inc.php 修改,勿動原檔。
| 參數 | 設定值 | 說明 |
|---|---|---|
$cfg['PmaAbsoluteUri'] | 'https://your-domain.com/phpmyadmin' | 完整存取 URL,必須正確否則重導向失敗 |
$cfg['Servers'][$i]['auth_type'] | 'cookie' | 生產環境必用 cookie/http,避免 config 明文帳密 |
$cfg['Servers'][$i]['user'] | 'your_db_user' | 資料庫連線帳號 |
$cfg['Servers'][$i]['password'] | 'your_db_pass' | auth_type=config 時生效;cookie 模式由登入表單輸入 |
$cfg['blowfish_secret'] | 'long_random_string_32chars+' | Cookie 加密金鑰,長度 ≥ 32 字元,隨機生成 |
$cfg['DefaultLang'] | 'zh-tw' | 介面語言(繁體中文) |
$cfg['DefaultCharset'] | 'utf-8' | 預設字元集 |
$cfg['Servers'][$i]['host'] | 'localhost' | MySQL 伺服器位址 |
<?php
$cfg['blowfish_secret'] = 'your_32_char_random_string_here'; // 必填
$i = 0;
$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false; // 禁止無密碼登入
?>
chmod 755 phpmyadmin、chmod 644 config.inc.php。瀏覽器訪問 https://your-domain.com/phpmyadmin/,輸入資料庫帳號密碼即可進入管理介面。