Sails JS安装和数据库连接错误

时间:2015-12-24 06:59:32

标签: mysql sails.js

我是 sails.js 的新手,我正在尝试使其正常工作但无法正确安装。

在安装过程中,首先,它提供了 MSB4132问题 然后我安装了 visual studio 2010 来解决该问题,但随后开始显示大约2页的红色文本错误。 enter image description here

enter image description here

enter image description here

由于这个问题sails新项目工作正常但当我尝试将它连接到我的sql然后它显示问题。

我为连接到mysql所做的更改

SailsTest / config / connection.js

 TestServer: {
    adapter: 'sails-mysql',
    host: 'localhost',
    user: 'root',
    password: '',
    port: 4343,
    database: 'sailstest'
  },

SailsTest / config / model.js

connection: 'TestServer',
migrate: 'safe'

SailsTest / api / controller / userController.js

module.exports = {
    get:function(req, res){
        User.find()
            .exec(function(err, users){
                if(err){
                    console.log(err);
                    return res.json(err);
                }
                return res.json(users);
            })
    }
};

SailsTest / config / route.js

  '/': {
    view: 'homepage'
  },
    '/user/get':'UserController.get'

毕竟这一切 http://localhost:1337/user/get 显示以下错误

{
  "error": "E_UNKNOWN",
  "status": 500,
  "summary": "Encountered an unexpected error",
  "raw": {}
}

这是错误日志。

    Error (E_UNKNOWN) :: Encountered an unexpected error
: Could not connect to MySQL:
Error: connect ECONNREFUSED 127.0.0.1:4343
    at afterwards (C:\Users\Ashish\Desktop\SailsTest\node_modules\sails-mysql\lib\connections\spawn.js:72:13)
    at C:\Users\Ashish\Desktop\SailsTest\node_modules\sails-mysql\lib\connections\spawn.js:40:7
    at Handshake.onConnect (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\Pool.js:54:9)
    at Handshake.Sequence.end (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
    at Protocol.handleNetworkError (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\protocol\Protocol.js:358:14)
    at PoolConnection.Connection._handleNetworkError (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\Connection.js:382:18)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1256:8)
    at nextTickCallbackWith2Args (node.js:455:9)
    at process._tickDomainCallback (node.js:410:17)

0 个答案:

没有答案