Mongodb install & uninstall

  Image result for mongodb
MongoDB is an open-source document database and leading NoSQL database. MongoDB is written in C++. This tutorial will give you great understanding on MongoDB concepts needed to create and deploy a highly scalable and performance-oriented database.

Explanation: 
This operation executes the index.js script in a mongo shell that connects to the mydb database on the mongod instance accessible via the localhost interface on port 27017. localhost:27017 is not mandatory as this is the default port mongodb uses. Also, you can run a .js file from within mongo console.
 >load("index.js")

install the mongo db in Terminal(ubundu 16.04)

Step 1: Import the public key used by the package management system. 


sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5


Image result for installStep 2: Create a list file for MongoDB.echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list


Step 3: Reload local package database.
sudo apt-get update

Step 4: Install the MongoDB packages.

sudo apt-get install -y mongodb-org



Install a specific release of MongoDB.

To install a specific release, you must specify each component package individually along with the version number, as in the following example:

sudo apt-get install -y mongodb-org=3.6.0 mongodb-org-server=3.6.0 mongodb-org-shell=3.6.0 mongodb-org-mongos=3.6.0 mongodb-org-tools=3.6.0

If you only install mongodb-org=3.6.0 and do not include the component packages, the latest version of each MongoDB package will be installed regardless of what version you specified.



Run MongoDB Community Edition

Image result for running mongodb
Step 1: Start MongoDB.
sudo service mongod start


Step 2: Verify that MongoDB has started successfully    
Verify that the mongod process has started successfully by checking the contents of the log file at/var/log/mongodb/mongod.log for a line reading
[initandlisten] waiting for connections on port <port>
<port> : 27017
Step 3: Stop MongoDB.sudo service mongod stop
Step 4: Restart MongoDB.   
sudo service mongod restart


Uninstall MongoDB Community Edition

To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.


Image result for uninstall
Step 1: Stop MongoDB.
sudo service mongod stop


Step 2: Remove Packages.      
sudo apt-get purge mongodb-org*

Step 3: Remove Data Directories.


sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

Comments

Popular posts from this blog

Pseudocode

Bootstrap

Mongodb