问题描述
我正在尝试使用mysql作为数据库,但是我不知道如何获取config/adapters.js以使用config/local.js中的mysql信息进行连接.存储连接信息以使sails-mysql可以连接的正确方法是什么?
I'm trying to use mysql as my database, but I can't figure out how to get my config/adapters.js to use mysql information in config/local.js to connect. What's the correct way to store the connection information so that sails-mysql can connect?
推荐答案
config/local.js 合并在所有其他配置之上.因此,您只需在其中放置自己的adapters
键:
config/local.js is merged on top of all other configuration. So you can just put your own adapters
key in there:
{
adapters: {
default: 'myLocalAdapter',
myLocalAdapter: {
module: 'sails-mysql',
host: 'localhost',
user: 'root',
password: 'password',
database: 'database'
}
}
}
它将被Sails拾起并使用.
and it'll be picked up and used by Sails.
编辑在Sails v0.10.x中,使用键connections
而不是adapters
,因为这两个现在已经区分了,并且连接现在保存了身份验证信息.最初的答案是对于早期版本的Sails.
EDIT In sails v0.10.x, use the key connections
instead of adapters
as the two are now differentiated and connections now hold authentication info. The original answer was for an earlier version of sails.
这篇关于使用local.js存储Sails-mysql密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!