Ali Cloud server installation method of mongodb
- 2020-12-05 17:27:21
- OfStack
1. Download mongodb
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.9.tgz
2. Unzip
tar zxvf mongodb-linux-x86_64-3.2.9.tgz
3. Create data folders, log files, etc
mkdir -p /usr/local/mongodb/data
touch /usr/local/mongodb/mongod.log
touch /usr/local/mongodb/mongodb.conf
4. Start
Go to the bin directory for mongo to execute
(1) Start parameter
./mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/mongod.log --logappend --port=27017 --fork
(2) Configuration file startup
./mongod --config /usr/local/mongodb/mongodb.conf
The configuration file is as follows
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/mongod.log
logappend = true
port = 27017
fork = true
auth = true
5. Create a user (after the creation, you need to configure a firewall in the Aliyun console to connect)
db.createUser({'user':" The user name ","pwd":" password ",roles:[{'role':" Role permissions ( dbAdmin ) ",db:"admin"}]})
conclusion