Install MongoDB

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:

Install MongoDB Picture 1

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:

Install MongoDB Picture 2

According to Tutorialspoint

Previous article: Advantages of MongoDB

Next article: Modeling data in MongoDB

4.4 ★ | 5 Vote

May be interested

  • Shard in MongoDBShard in MongoDB
    sharding is a process of storing data records across multiple devices and it is a method of mongodb to meet the requirement for increasing data. when the size of the data increases, a single device cannot be enough to store data.
  • Learn about Java Driver in MongoDBLearn about Java Driver in MongoDB
    in the following article, we will introduce you some basic features of mongodv java driver as well as how to deploy and apply in practice.
  • Map Reduce in MongoDBMap Reduce in MongoDB
    in mongodb documentation, map-reduce is a data processing system that condenses a large amount of data into useful overall results. mongodb uses mapreduce command for map-reduce operation. in general, map reduce is used to handle large data sets.
  • Aggregation in MongoDBAggregation in MongoDB
    aggregation can be understood as aggregation. the aggregation operation handles data records and returns calculated results. the operations group the values ​​from multiple documents together, and can perform multiple operations on the grouped data to return a single result. in sql, count (*) and group by are equivalent to aggregation in mongodb.
  • Data modeling in MongoDBData modeling in MongoDB
    data in mongodb has a flexible schema. documents in the same collection need not have the same set of fields or structures, and common fields in collection documents can keep different data types.
  • How to use Aggregation Pipeline in MongoDBHow to use Aggregation Pipeline in MongoDB
    if you are using mongodb's mapreduce, it is best to switch to aggregation pipeline for more efficient computation.
  • GridFS in MongoDBGridFS in MongoDB
    gridfs is the mongodb specification for storing and collecting large files such as images, audio, video files, etc. it is a type of file system to store files but its data is stored inside mongodb collections. .
  • Query analysis in MongoDBQuery analysis in MongoDB
    analyzing queries is a very important aspect to assess the effectiveness of database and the effectiveness of the designed index. we will explore the two most frequently used queries, $ explain and $ hint.
  • Projection in MongoDBProjection in MongoDB
    in mongodb, projection's meaning is to select only the necessary data instead of selecting the entire data of a document. if a document has 5 fields and you only need 3 fields, you should only select 3 fields from that document.
  • Reference Database in MongoDBReference Database in MongoDB
    as shown in the relationship chapter in mongodb, to deploy a standardized database structure in mongodb, we use the referenced relationship concept, also known as manual references, in which we manipulate to store the id of the documents referenced in another document.