Method of installing mongodb under Linux ubuntu


1. Download and install corresponding version

The official website download address is as follows:

www.mongodb.org/downloads

# through CURL download
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.2.0.tgz

# Unpack the
tar -zxvf mongodb-linux-x86_64-ubuntu1404-3.2.0.tgz

# mobile
mv mongodb-linux-x86_64-ubuntu1404-3.2.0/ /usr/local/mongodb

# Add environment variables
export PATH=/usr/local/mongodb/bin:$PATH

2. Database directory creation

The MongoDB data is stored in the db directory in the data directory, but this directory is not automatically created during the installation process, so you need to manually create the data directory and create the db directory in the data directory.

Note: /data/db Is the default database path to start for MongoDB (wAM22en).

3. Install via ES25en-ES26en

// Configure the public key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

sudo apt-get update

sudo apt-get install -y mongodb-org
// Complete the above installation step configuration mongodb Location of the database

sudo mongod --dbpath /data/db

// Start the mongod
sudo service mongod start

conclusion

The above is the whole content of this article, I hope the content of this article can bring 1 definite help to your study or work, if you have any questions, you can leave a message to communicate.