Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

phpMyAdmin 登入報 1130 錯誤(Host not allowed)完美解決:授權 root 遠程連線

編輯:關於伺服器

錯誤現象

命令列 mysql -u root -p 正常,但 phpMyAdmin 登入報錯:

#1130 - Host 'localhost' is not allowed to connect to this MySQL server

根因

MySQL user 表中 root 帳號的 Host 欄位僅允許 localhost(Unix Socket),不允許 TCP/IP 連線(phpMyAdmin 走 127.0.0.1:3306)。

解決步驟

mysql -u root -p
USE mysql;
SELECT Host FROM user WHERE User='root';
UPDATE user SET Host='%' WHERE User='root';
FLUSH PRIVILEGES;
SELECT Host FROM user WHERE User='root';

% 為通配符,允許所有 IP 連線。生產環境建議改為具體 IP(如 127.0.0.1、10.0.0.%)。

驗證

重啟 MySQL 服務(service mysqld restart),phpMyAdmin 即可正常登入。

安全提醒

  • 生產環境嚴禁使用 Host='%' 暴露 root
  • 建立專用應用帳號、最小權限、指定來源 IP
  • 啟用 SSL 連線、防火牆限制 3306 埠僅內網可達
Copyright © Windows教程網 All Rights Reserved