首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 網頁程式設計 >> PHP 程式設計 >> PHP 相關知識

修改 MySQL 密碼後 phpMyAdmin 無法登錄的配置同步指南

     編輯:PHP 相關知識

問題現象

#1045 - Access denied for user 'root'@'localhost' (using password: YES)

核心解決:同步 config.inc.php 密碼

  1. 編輯 phpMyAdmin/config.inc.php。
  2. 修改用戶名密碼:
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'new_mysql_password';
  3. 若使用 Cookie 認證(auth_type='cookie'),**必須**設置 blowfish_secret:
    $cfg['blowfish_secret'] = 'random_32_char_string'; // 如 'a1b2c3d4e5f6...'
  4. 保存,無需重啟服務,刷新瀏覽器即可登錄。

Linux 環境 Session 失敗導致無提示跳轉

現象

輸入正確密碼也無錯誤提示,直接跳回登錄頁。

解決

  1. php.ini:session.save_path = "/var/lib/php/session"
  2. 目錄權限:
    chown -R www-data:www-data /var/lib/php/session
    chmod 770 /var/lib/php/session
  3. 重啟 PHP-FPM:systemctl restart php-fpm 或 service php-fpm restart。

通用配置模板(config.inc.php 關鍵段)

$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'your_password';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['blowfish_secret'] = 'your_32_char_random_secret'; // 必填
$cfg['DefaultLang'] = 'zh_CN';

遠程訪問額外設置

  • $cfg['Servers'][$i]['host'] = 'remote_ip';
  • MySQL 用戶授權遠程:GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
  • 防火牆開放 3306 端口。
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved