sails.js:mysql connection failed ReferenceError: localMysql is not defined

sails.js:mysql connection failed ReferenceError: localMysql is not defined

我正在尝试将 mysql 数据库连接到我的 sailsjs 应用程序

config/connections.js

localMysql:{ //arbitrary name
        adapter: 'sails-mysql',
        host: '127.0.0.1',
        port: 3306,
        user: 'root',
        password: 'root'
    }

并在 config/models.js

module.exports.models = {
    connection:localMysql

}

But i got the following error include-all attempted to require(/var/www/node/sails-test/config/models.js), but an error occurred:: Details:ReferenceError: localMysql is not defined

你需要传递一个 string:

module.exports.models = {
    connection: 'localMysql'
};

http://sailsjs.com/documentation/reference/configuration/sails-config-connections