gpt4 book ai didi

javascript - 将 nodejs 连接到谷歌云 SQL

转载 作者:行者123 更新时间:2023-11-29 02:55:37 25 4
gpt4 key购买 nike

我正在尝试将 nodejs 实例连接到我的谷歌云 SQL 数据库。它失败了。

我运行命令

node server.js

得到错误

Problem with MySQL Error: connect ENETUNREACH

这是我的 server.js 文件

var gcloud = require("gcloud");
var express = require("express");
var mysql = require("mysql");
var app = express();
var connection = mysql.createConnection({
host : "2001:****:****:*:****:****:****:****",
user : "root",
password : "*****",
database : "scripto_5_k"
});
/* Connection to Database */
connection.connect(function(error){
if(error)
{
console.log("Problem with MySQL "+error);
}
else
{
console.log("Connected with Database ");
}
});
/*start the server */
app.listen(3000,function(){
console.log("its started on PORT 3000");
});

我已经在开发人员控制台访问了我的 sql 数据库,并允许我家的 ip 地址和 Node js 实例,但我似乎找不到问题。

非常感谢任何帮助。

更新 1

我用这个结果 ping 了 IPv6 地址

C:\Users\joe>ping 2001:****:****:*:****:****:****:****

Pinging 2001:****:****:*:****:****:****:**** with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 2001:****:****:*:****:****:****:****:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

但是我已经从gcloud的sql选项卡中的属性中获取了ip。

最佳答案

主机地址可能有误。你试过ping它吗?

关于javascript - 将 nodejs 连接到谷歌云 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30925856/

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