Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongodb database installation & set administrator password (separate mongo, no copy set)

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

# # initialize system environment, refer to documentation: server system environment initialization, Centos7 system

# download and install mongodb

Mkdir-p / server/src / server/logsgroupadd mongoduseradd-s / sbin/nologin-g mongod mongod cat / etc/passwd | grep mongocd / server/src # # install mongodb version 3.0.7, if other versions are required Download https://fastdl.mongodb.org/linux/wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.0.7.tgz tar zxvf mongodb-linux-x86_64-rhel70-3.0.7.tgz mv mongodb-linux-x86_64-rhel70-3.0.7 / usr/local/mongodbmkdir-p / data/mongodb/dbmkdir / data/mongodb/logtouch / data/mongodb/log/mongo.logchmod 644! $chown-R mongod on the official website Type=forkingPIDFile=/data/mongodb/db/mongod.lockExecStart=/usr/local/mongodb/bin/mongod / data/mongodbyum-y install treetree / datavim / lib/systemd/system/ mongod.service[ Service] Type=forkingPIDFile=/data/mongodb/db/mongod.lockExecStart=/usr/local/mongodb/bin/mongod-- dbpath=/data/mongodb/db-- logpath=/data/mongodb/log/mongo.log-- fork-- port 27017-- logappend-- authExecReload=/bin/kill-s HUP $MAINPIDExecStop=/bin/kill-s QUIT $MAINPIDPrivateTmp=true [Install] WantedBy=multi-user. Targetsystemctl enable mongod.servicesystemctl start mongod.serviceps aux | grep mongo | grep-v 'grep'systemctl status mongod.service##mongo starts the process parsing ps aux | grep mongo | grep-vE "cp2 | grep" root 75815 0.1 658320 72384? Sl 17:50 0:08 / usr/local/mongodb/bin/mongod-- dbpath=/data/mongodb/db-- logpath=/data/mongodb/log/mongo.log-- fork-- port 27017-- logappend-- auth # # parsing # mongod is the port used to start the mongodb service #-portmongodb startup #-- dbpath specifies a directory as the mongodb database storage path #-- logpath log file storage path #-automatic accumulation of logappend log files Instead of overwriting #-- fork starts the Mongdb service in the background #-- directoryperdb stores each database in a separate directory

# add mongo programs to environment variables

Echo "export PATH=/usr/local/mongodb/bin:$PATH" > > / etc/profilesource! $echo $PATH

# enter mongo

Mongo # # default login method, use the mongo service started at the default port 27017, go directly to mongo-- port=27027 # # specify port 27027 to start the mongo service, and add the port number to start mongo 103.56.195.5mongo 27017 # # login to the specified remote host mongo service, you can use this to test whether the peer firewall is open.

# create an administrator account

Use admindb.createUser ({user: "mongo_admin", pwd: "xxx", roles: [{role: "root", db: "admin"}]}) db.auth ('mongo_admin','xxx')

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report