Install MongoDB

Instructions for installing MongoDB on Windows.

Install MongoDB on Windows

To install MongoDB on Windows, first download the latest MongoDB version from: http://www.mongodb.org/downloads. Make sure you have downloaded the MongoDB version correctly with your Windows version. To get the Windows version, open the command prompt and execute the following command:

 C : > os os get osarchitecture OSArchitecture 64 - bit C : > 

MongoDB 32-bit version only supports databases smaller than 2GB and only suitable for research and calculation purposes.

Now, extract the file you downloaded into C: or any other location. Make sure the folder name is mongodb-win32-i386- [version] or mongodb-win32-x86_64- [version]. Here, [version] is the downloaded MongoDB version.

Open the command prompt (command prompt) and run the following command:

 C : > move mongodb - win64 - * mongodb 1 dir ( s ) moved . C : > 

In case you have placed mongodb in a different location, you follow that path using the cd FOOLDER / DIR command and run the above commands.

MongoDB needs a Folder to store its files. The default location for MongoDB folder is c: datadb. Therefore, you need to create this folder using the command prompt. Execute the following command sequence:

 C : >md data C : md datadb 

If you have MongoDB installed at a different location, you need to specify an alternative path for the datadb by setting dbpath in mongodb.exe.

At the command prompt, navigate to the bin directory that is located inside the mongodb installation folder. Suppose your installation folder is D: set upmongodb.

 C : UsersXYZ > d : D : >cd "set up" D : set up > cd mongodb D : set upmongodb > cd bin D : set upmongodbb in > mongod . exe -- dbpath "d:set upmongodbdata" 

These commands will display the Waiting for connections message on the console to indicate that the mongodb.exe process is running successfully.

Now, to run mongodb, you need to open another command prompt and notify the following command:

 D : set upmongodbb in > mongo . exe MongoDB shell version : 2.4 . 6 connecting to : test > db . test . save ( { a : 1 } ) > db . test . find () { "_id" : ObjectId ( 5879b0f65a56a454 ), "a" : 1 } > 

This command will indicate that mongodb has been installed and successfully run. Next, when you run mongodb, you only need to notify the commands.

 D : set upmongodbb in > mongod . exe -- dbpath "d:set upmongodbdata" D : set upmongodbb in > mongo . exe 

Install MongoDB on Ubuntu

Run the following command to import MongoDB's public GPG Key:

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

Create a /etc/apt/sources.list.d/mongodb.list file using the following command:

 echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee / etc / apt / sources . list . d / mongodb . list 

Now, the following command message to update Repository:

 sudo apt - get update 

Then, install MongoDB using the command:

 apt - get install mongodb - 10gen = 2.2 . 3 

In the above settings, 2.2.3 is the published mongodb version. You should install the latest version. At this point, mongodb has been successfully installed.

Start MongoDB

 sudo service mongodb start 

Stop MongoDB

 sudo service mongodb stop 

Restart MongoDB

 sudo service mongodb restart 

To use MongoDB, you use the command.

 mongo 

This command will connect you to the running mongodb instance.

MongoDB Help

To get the list of commands, you write db.help () in Mongodb Client. This command will help you list the following commands:

Picture 1 of Install MongoDB

MongoDB Statistics

To get statistics about MongoDB Server, you compose db.stats () command in MongoDB Client. This command will show the database name, Collection number and Documents in that database. The result of the command is as follows:

Picture 2 of Install MongoDB

According to Tutorialspoint

Previous article: Advantages of MongoDB

Next article: Modeling data in MongoDB

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile