您的位置:首页 > 博客中心 > 数据库 >

mongodb3.6.4安装

时间:2022-03-15 08:31

groupadd -g 800 mongodb
useradd -u 801 -g mongodb mongodb
cd /usr/local/
mkdir mongodb
cd mongodb/
#mkdir bin
mkdir conf
mkdir log
mkdir data

cd /root/
wget
tar xf mongodb-linux-x86_64-rhel62-3.6.4.tgz
cd mongodb-linux-x86_64-rhel62-3.6.4
cp * /usr/local/mongodb
cd /usr/local
chown -R mongodb.mongodb mongodb/

cd /root/
vi .bash_profile
export PATH=/mongodb/bin:$PATH
source .bash_profile

vim /usr/local/mongodb/conf/mongodb.conf
logpath=/usr/local/mongodb/log/mongodb.log
dbpath=/usr/local/mongodb/data
#directoryperdb=true
port=27017
bind_ip=0.0.0.0
logappend=true
fork=true
cpu=true
auth=true

netstat -nputl
mongod -f /usr/local/mongodb/conf/mongodb.conf
mongod --shutdown -f /usr/local/mongodb/conf/mongodb.conf

mongo
db
show dbs

use admin
db.auth("admin","xld.2018")
db.system.users.find()
db.createUser({user:"admin",pwd:"xld.2018",roles:["root"]}) 创建超级管理员
db.createUser({user:"xwgl",pwd:"xld.2018",roles:[{ role: "dbAdmin", db: "xwgl" }]}) 创建单个数据库管理员

热门排行

今日推荐

热门手游