如何解决 CentOS 中的 "Failed to connect to MySQL Host" 错误

How to solve "Failed to connect to MySQL Host" Error in CentOS

Failed to connect to MySQL: Host 'IP-Address' is not allowed to connect to this MySQL server.

CentOS 服务器是我们的 MySql 主机服务器,我想从另一个客户端网络主机服务器连接 mysql。

我该怎么做?

尝试查看 iptables 并检查是否允许从主机连接到服务器,允许端口 3306

为您 mysql 方的主机添加用户: mysql -p, GRANT ALL PRIVILEGES ON your_database.* TO your_user@ip_of_your_host IDENTIFIED BY 'your_password';

将主机用户添加到您的 mysql 端并写下命令。

mysql -p,
GRANT ALL PRIVILEGES ON DB_NAME.* TO USER@HOST_IP IDENTIFIED BY 'PASSWORD';

注意:你的端口必须是3306

试试这个

mysql -p GRANT ALL PRIVILEGES ON DB_NAME.* TO USER@HOST_IP IDENTIFIED BY 'PASSWORD';

我上个月用了两次