没有互联网连接的数据库没有连接

时间:2015-08-28 16:32:47

标签: mysql sails.js

我在使用 Xampp mysql数据库与 SailsJS 时遇到此问题。我的应用程序在本地运行,连接代码如下:

someMysqlServer: {
adapter: 'sails-mysql',
host: "localhost",
user:"root",
port     : '3306',
database: 'school'
}

当我启动Xamp控制面板没有互联网连接时,即使 http://localhost 的请求也连接到phpmyadmin,但是我的sails控制台说 p>

error: A hook (`orm`) failed to load!
error: Error (E_UNKNOWN) :: Encountered an unexpected error
: Could not connect to MySQL:
Error: getaddrinfo ENOENT
at afterwards (D:\SchoolProject\node_modules\sails-    mysql\lib\connections\spawn.js:72:13)
at D:\SchoolProject\node_modules\sails-mysql\lib\connections\spawn.js:40:7
at Handshake.onConnect (D:\SchoolProject\node_modules\sails-mysql\node_modules\mysql\lib\Pool.js:54:9)
at Handshake.Sequence.end (D:\SchoolProject\node_modules\sails-mysql\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
at Protocol.handleNetworkError (D:\SchoolProject\node_modules\sails-mysql\node_modules\mysql\lib\protocol\Protocol.js:355:14)
at PoolConnection.Connection._handleNetworkError     (D:\SchoolProject\node_modules\sails-mysql\node_modules\mysql\lib\Connection.js:367:18)
at Socket.emit (events.js:107:17)
at net.js:950:16
at process._tickDomainCallback (node.js:381:11)

虽然相同的应用程序适用于互联网连接。我不能想出任何想法,请?????

1 个答案:

答案 0 :(得分:0)

主机替换主机:“localhost”:“127.0.0.1” 我认为它会奏效。