Linux operating system installation Mongodb (b)

1, download and install Mongodb

cd进入/usr/local/src
cd /usr/local/src

wget downloads

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.0.tgz

tar decompression

tar zxvf mongodb-linux-x86_64-2.6.0.tgz

Move the file to extract the installation directory

mv mongodb-linux-x86_64-2.6.0  /usr/local/mongodb

Create a storage path mongodb

mkdir  -p  /usr/local/mongodb/data/

Create a log file to store files mongodb

mkdir /usr/local/mongodb/logs/mongodb.log

2, start mongodb

/usr/local/mongodb/mongodb-linux-x86_64-2.6.0/bin/mongod --port 27017 --fork --dbpath=/usr/local/mongodb/mongodb-linux-x86_64-2.6.0/data/ --logpath=/usr/local/mongodb/mongodb-linux-x86_64-2.6.0/logs/mongodb.log --logappend&

an examination

netstat -lanp | grep "27017"

Mongodb into the database console

./mongo

Setting global mongodb

Adding Environment Variables

vi /etc/profile

Also used VI editor, add the following configuration

export PATH=$PATH:/usr/local/mongodb/bin

Press ESC, then: wq save and exit

The configuration files take effect immediately

source /etc/profile

Then you can use the global mongodb commands
into the console mongodb

mongo  #进入MongoDB控制台

show dbs #查看默认数据库

use admin  #切换到admin数据库

exit #退出MongoDB控制台
Published 118 original articles · won praise 26 · views 60000 +

Guess you like

Origin blog.csdn.net/qq_43147136/article/details/84784922