【问题标题】:sails.js:mysql connection failed ReferenceError: localMysql is not definedsails.js:mysql 连接失败 ReferenceError: localMysql is not defined
【发布时间】:2017-11-12 04:02:12
【问题描述】:

我正在尝试将 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

}

但我收到以下错误 include-all 试图 require(/var/www/node/sails-test/config/models.js),但是出错了 发生:: Details:ReferenceError: localMysql is not defined

【问题讨论】:

    标签: javascript mysql node.js sails.js


    【解决方案1】:

    你需要传递一个string

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

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

    【讨论】:

    • 让我试试你的答案
    • 你有这个答案吗https://stackoverflow.com/questions/44541025/sails-js-session-undefined-on-page-refresh
    猜你喜欢
    • 1970-01-01
    • 2020-08-14
    • 2022-11-19
    • 2014-03-03
    • 2018-12-26
    • 2020-06-14
    • 2019-02-08
    • 2015-11-19
    • 2019-11-10
    相关资源
    最近更新 更多