In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Development old driver has a demand for me to install a mongodb, in the Internet to consult some information tested several kinds of error is not the database command does not match, the following is relatively simple and not easy to error.
Get binary compressed package
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.8.tgz
Extract to installation directory, create data directory, configure data directory path later in configuration file
tar -xf mongodb-linux-x86_64-rhel62-3.2.8.tgz -C /usr/local/
cd /usr/local/
mv mongodb-linux-x86_64-rhel62-3.2.8 mongodb
mkdir /usr/local/mongodb/data
edit the configuration file
vim /usr/local/mongodb/mongodb.conf
#Port
port=27017
#Data file storage directory
dbpath= /usr/local/mongodb/data
#Log file storage directory
logpath= /usr/local/mongodb/mongodb.log
#Write a journal by appending
logappend=true
#Enabled as a daemon, i.e. running in the background
fork=true
#Maximum number of simultaneous connections
maxConns=500
#Allow only local access
#bind_ip=127.0.0.1
#Enable validation
#auth = true
Configure environment variables
echo 'export PATH=$PATH:/usr/local/mongodb/bin'>>/etc/profile
. /etc/profile
Start mongodb
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
Connect to MongoDB
mongo
Create an administrative user (I don't know whether it is for the development user or for ordinary users in production)
use admin
db.createUser({user:'root',pwd:'woshichenshifei',roles:[{role:'dbAdminAnyDatabase',db:'admin'},{role:'userAdminAnyDatabase',db:'admin'}]})
Check whether the creation is successful and verify whether the user authentication is correct
db.auth('root','woshichenshifei')
If the developer needs to modify the password, modify it again.
db.changeUserPassword('root','chenshifei')
Create and delete databases and regular users of databases
use chenshifei
db.createUser({user:'chenshifei',pwd:'chenshifei',roles:[{role:'readWrite',db:'chenshifei'}]})
db.dropUser('chenshifei')
exit
quit()
Open configuration file auth verify, restart mongodb and reconnect
kill `ps -ef|grep mongodb|awk 'NR==1{print $2}'`
Remove #before auth
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
mongo localhost:27017/admin -u root -p chenshifei
Give the connection address, user, password to development or dba
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.