gpt4 book ai didi

php - 连接失败: Host 'xx.xx.xx.xx' is not allowed to connect to this MySQL server - AJAX and AWS

转载 作者:行者123 更新时间:2023-11-29 12:16:21 26 4
gpt4 key购买 nike

我正在尝试将一些数据从客户端浏览器插入到 AWS 服务器上的 MySQL 数据库。

该代码在 godaddy 上运行,因此看起来像是权限/安全问题。

$servername = "xx.xx.xx.xx";
$username = "user";
$password = "mypass";
$dbname = "dbName";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO mytable ('email')
VALUES ('" . $email . "')";

echo $sql;

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();

我收到错误消息“连接失败:主机 x.x.x.x 不允许连接到此 MySQL 服务器”

如何允许从客户端浏览器连接到此?

我已经注释掉了 bind-address = 127.0.0.1

最佳答案

如果Mysql是远程主机,则允许使用源系统的私有(private)IP地址,因为AWS默认使用私有(private)IP地址进行通信。

关于php - 连接失败: Host 'xx.xx.xx.xx' is not allowed to connect to this MySQL server - AJAX and AWS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29729820/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com