【发布时间】:2017-06-21 17:27:11
【问题描述】:
我已遵循本指南https://cloud.google.com/community/tutorials/run-sailsjs-on-google-app-engine 关于如何将 Sails 部署到 Google App Engine。 但是,我的应用程序使用 MySQL 作为数据库,我在“connection.js”中进行了这样的设置。
mysql: {
adapter: 'sails-mysql',
host: '104.199.196.99', // Internal IP Address of the Cloud SQL Instance
user: 'root',
password: 'xxxxxx',
database: 'xxxxxxxx'
}
我在尝试连接 Cloud SQL 时遇到的错误(当我请求登录时涉及到数据库的连接)是:
Sending 500 ("Server Error") response:
Error (E_UNKNOWN) :: Encountered an unexpected error
Could not connect to MySQL:
Error: connect ETIMEDOUT
我的设置是否正确?
【问题讨论】:
-
请赐教,云SQL是在默认端口(3306)上运行的吗?否则它不会连接,因为您没有在 connections.js 文件中提到端口?
-
我尝试将端口指定为 3306,但没有成功。在 Google Cloud Shell 中,我尝试了“telnet
3306”,但无法访问。相反,可以通过端口 3307 访问 Cloud SQL 实例。我尝试在 connection.js 文件中指定这两个端口,但仍然没有结果。我有另一个有权连接到 Cloud SQL 的 Compute Engine 实例(我为其分配了静态 IP 地址)一个简单的命令“mysql --host= --user=root --密码”没有端口可以连接。 -
此外,Cloud SQL 拥有允许该项目中所有应用连接的权限。
-
你把两个端口都放了?我不明白。你用过 mysql: { adapter: 'sails-mysql', host: '104.199.196.99', // Cloud SQL Instance 的内部 IP 地址 user: 'root', password: 'xxxxxx', database: 'xxxxxxxx' port : 3007 }
标签: mysql node.js google-app-engine sails.js google-cloud-sql