gpt4 book ai didi

mysql - 拒绝用户访问(NodeJS 和 MySQL)

转载 作者:行者123 更新时间:2023-11-29 04:36:39 24 4
gpt4 key购买 nike

我正在尝试连接到我在我的域中的数据库。我创建了一个名为 public_guests 的用户,它可以访问该数据库。

我正在使用 NodeJS 创建连接,但出现以下错误。

ER_ACCESS_DENIED_ERROR: Access denied for user

错误后面是我的IP地址等

这是我的代码:

mysql = require("mysql");

var connection = mysql.createConnection({
host: "humadshah.com",
username: "public_guests",
password:"hello",
databse:"my_quotes"
});

connection.connect(function(error){
if(error){
console.log("Couldn't connect :( Error: " + error);
} else {
console.log("Connected successfully~!");
}
});

我以前从未使用过数据库,所以我预计这在某处是一个非常愚蠢的错误。

最佳答案

据我所知,这不是 Node.js 的问题。

这是用户在特定 IP 地址的权限问题, 并在错误消息中指出:

用户@some IP 的访问被拒绝

So try to give your root permission for IP where your Node.js instance is running port xxx.xx.xx.xx.

关于mysql - 拒绝用户访问(NodeJS 和 MySQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39682876/

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