1. 程式人生 > >mongodb3.6.4安裝

mongodb3.6.4安裝

mongodb

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 https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.6.4.tgz
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" }]}) 創建單個數據庫管理員

mongodb3.6.4安裝