Brew安装MongoDB
原创小于 1 分钟
本文介绍,使用Brew安装MongoDB
参考链接
安装操作步骤
brew tap mongodb/brew
brew search mongodb
brew install [email protected]
a configuration file: /usr/local/etc/mongod.conf
a log directory path: /usr/local/var/log/mongodb
a data directory path: /usr/local/var/mongodb
brew services start mongodb-community
brew services stop mongodb-community
To have launchd start mongodb/brew/mongodb-community now and restart at login:
brew services start mongodb/brew/mongodb-community
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
初始化MongoDB步骤
>mongo
>show dbs
>use admin
>db.createUser({user:'admin',pwd:'abccba',roles:['__system']})
>show users
vim /usr/local/etc/mongod.conf
security.authorization
security:
authorization: enabled
ps aux | grep -v grep | grep mongod
>mongo
>use admin
>db.auth('admin','abccba')
>
>show roles
>
>db.createUser(
{
user: "admin",
pwd: "dev_admin",
roles: [ "readWrite", "dbAdmin" ]
}
)
db.runCommand( {dropUser: "root"})
db.changeUserPassword("admin", "dev_admin")