Linux Mongodb 安裝 wgethttps://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.7.tgz
mkdir -p /data/re/mongodb/journal
mkdir -p /data/re/mongodb/log
touch /data/re/mongodb/log/mongodb.log
useradd mongodb -M -s /sbin/nologin
chown -R mongodb.mongodb /data/re/mongodb
mongo --port 你的端口
use admin
db.createUser(
{
user: "賬號",
pwd: "密碼",
roles: [ "readWrite", "dbAdmin" ]
}
)
db.auth("賬號", "密碼")
show collections
mongo --port 端口 -u "賬號" -p "密碼" --authenticationDatabase "admin"
use admin