linux install MongoDB

1. Install EPEL
Note that if epel has not been installed before, the installation will fail.
Install epel
rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6- 8.noarch.rpm

2. Install MongoDB

yum install mongodb mongodb-server  mongodb-devel

If you want to use it for php, continue to install the php extension
yum install php-pecl-mongo

3. Configure /etc/mongodb.conf

    port = 27017 #Port number
    fork = true
    logpath = /var/log/mongodb/mongodb.log #Log path

    pidfilepath = /var/run/mongodb/mongodb.pid can specify the storage location of process files

    dbpath =/var/lib/mongodb #Database path
    journal = true
    auth = true #Turn on auth, indicating that the username and password can be verified   

3 Start

service mongod start #Start
mainly depends on whether the terminal display is ok

netstat -tpnl|grep 27017 #View
//Use this command to check to see if port 27017 is occupied by mongo to determine if it is running successfully

4. Add an administrator account
mongo #connect
use admin

//Add user
db.addUser('root','123456')

mongo3.6:

db.createUser({user:"root",pwd:"pass",roles:["dbAdmin"]})

//Log in

db.auth("root", "123456")

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326928686&siteId=291194637