标签:span col profile version config inux 创建数据库 mongodb 日志文件
1:安装
mkdir -p /app/mongodb
tar zxvf mongodb-linux-x86_64-rhel62-3.4.6.tgz
vi .bash_profile
PATH=$PATH:$HOME/bin
PATH=$PATH:/app/mongodb/mongodb-linux-x86_64-rhel62-3.4.5/bin
export PATH
--让配置文件生效
source .bash_profile
--在/app/mongodb目录下创建mongo.conf
dbpath=/app/mongodb/data
logpath=/app/mongodb/logs/mongo.log
logappend=true
journal=true
quiet=true
port=7979
fork=true
--创建目录
/app/mongodb/data
--创建日志文件
/app/mongodb/logs/mongo.log
2:创建数据库以及授权信息
$ mongo 127.0.0.1:7979 > use gwzh switched to db test > db.createUser({user:"test",pwd:"test",roles:[{role:"readWrite",db:"test"}]}) Successfully added user: { "user" : "test", "roles" : [ { "role" : "readWrite", "db" : "test" } ] } >
3:以授权模式启动
mongod --config mongodb/mongo.conf --auth
4:授权认证登录
$ mongo 127.0.0.1:7979
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:7979
MongoDB server version: 3.4.6
> use test
switched to db test
> db.auth(‘test‘,‘test‘)
1
>
标签:span col profile version config inux 创建数据库 mongodb 日志文件
原文地址:https://www.cnblogs.com/yshyee/p/9091730.html