phpMyAdmin 是基於 Web 的 MySQL 管理神器,支援遠程圖形化操作、SQL 編輯、資料匯入匯出、權限管理等。本文記錄在 RHEL6 + MySQL 5.6.4 + Apache + PHP 環境下,以 RPM 方式部署 phpMyAdmin 4.4.11 的完整流程,含依賴解決、配置細節、常見錯誤排查。
# 1. Apache rpm -qa | grep httpd # 需:httpd, httpd-tools, mod_ssl 等 # 2. MySQL rpm -qa | grep mysql # 需:mysql-server, mysql-devel, php-mysql 等 # 3. PHP 及擴展 rpm -qa | grep php # 關鍵:php-mbstring(RHEL 光盤無,需額外下載 rpm 安裝) echo 'extension=mbstring.so' >> /etc/php.ini service httpd restart
phpMyAdmin-4.4.11-all-languages.tar.gztar zxvf phpMyAdmin-4.4.11-all-languages.tar.gz -C /var/www/html mv /var/www/html/phpMyAdmin-4.4.11-all-languages /var/www/html/phpMyAdmin
/var/www/html/phpMyAdmin/libraries/config.default.php):| 參數 | 建議值 | 說明 |
|---|---|---|
| $cfg['Servers'][$i]['host'] | '192.168.8.24' | 允許遠程管理,填服務器實際 IP |
| $cfg['Servers'][$i]['auth_type'] | 'cookie' | 生產環境推薦 cookie 認證,本地測試可用 config |
| $cfg['Servers'][$i]['user'] | 'root' | MySQL 管理用戶 |
| $cfg['Servers'][$i]['password'] | 'your_password' | 對應密碼 |
| $cfg['Servers'][$i]['only_db'] | '' | 留空顯示所有庫,指定庫名則限制 |
| $cfg['DefaultLang'] | 'en' | 介面語言,中文可用 'zh_CN' 或 'zh_TW' |
| $cfg['blowfish_secret'] | 'random_string_32chars' | cookie 加密密鑰,auth_type=cookie 時必填 |
https://192.168.8.24/phpMyAdmin,出現登入介面即成功。php-mbstring 已安裝並 extension=mbstring.so 生效,重啟 httpd。GRANT ALL ON *.* TO 'root'@'192.168.8.%' IDENTIFIED BY 'pwd';、防火牆 3306、bind-address。 Alias /myadmin /var/www/html/phpMyAdmin 隱藏預設路徑。<Location /phpMyAdmin> Require ip 10.0.0.0/8 </Location>。phpMyAdmin 輕量強大,部署規範化是資料庫 Web 運維的基礎技能。