Dear readers of our blog, we'd like to recommend you to visit the main page of our website, where you can learn about our product SQLS*Plus and its advantages.
 
SQLS*Plus - best SQL Server command line reporting and automation tool! SQLS*Plus is several orders of magnitude better than SQL Server sqlcmd and osql command line tools.
 

REQUEST COMPLIMENTARY SQLS*PLUS LICENCE

Enteros UpBeat offers a patented database performance management SaaS platform. It proactively identifies root causes of complex revenue-impacting database performance issues across a growing number of RDBMS, NoSQL, and deep/machine learning database platforms. We support Oracle, SQL Server, IBM DB2, MongoDB, Casandra, MySQL, Amazon Aurora, and other database systems.

Installing MongoDB and start working with MongoDB on Windows

15 September 2020

Installing MongoDB and start working with MongoDB on Windows

To install MongoDB we download one distributed package from the official website www.mongodb.com/download/

The official website provides distribution packages for different platforms: Windows, Linux, MacOS, Solaris. And each platform has several distributions available. And there are two types of servers – Community and Enterprise. In this case, you must install the Community version. Although the Enterprise-version has slightly more features, it is only available in trial mode or by subscription.

At the time of writing, the latest version of the platform was version 4.0.4. The use of a particular version may slightly differ from other versions of the MongoDB platform.

To download the necessary functionality, we will select the desired operating system and the appropriate type of package:

Installing MongoDB

For Windows, you can select the type of package “ZIP”, i.e. load the server as an archive.

If an earlier version of MongoDB was already installed before installation, it must be deleted and all equally created databases must be deleted.

After downloading the archive package, unpack it in the folder C:\mongodb.

Contents of MongoDB package

If, after installation, we open the folder C:\mongodb\bin, we can find there a bunch of applications that perform a role. Let’s take a short look at them.

Contents of MongoDB package

  • bsondump: reads the contents of BSON files and converts them into a readable format, e.g. JSON
  • mongo: provides a console interface to interact with databases, a kind of console client.
  • mongod: MongoDB database server. It handles requests, controls the data format, and performs various operations in the background to manage the databases.
  • mongodump: database backup utility
  • mongoexport: a utility to export data in JSON, TSV or CSV formats
  • mongofiles: a utility to manage files on the GridFS system
  • mongoimport: a utility that imports data in JSON, TSV or CSV formats into the MongoDB database.
  • mongorestore: allows you to write data from a dump created by mongodump into a new or existing database.
  • mongos: a MongoDB routing service that helps process requests and locates data in a MongoDB cluster
  • mongorestat: represents the counter of operations with the dd
  • mongotop: provides a way to calculate the time spent on read-write operations in the database.

Creating a directory for the database and running MongoDB

After installation, it is necessary to create a directory on your hard disk, which will contain MongoDB databases.

On Windows by default, MongoDB stores databases on the path C:\data\db, so if you are using Windows, you need to create a directory. In Linux and MacOS the default directory is /data/db.

If you need to use some other file path then you can pass it on when you run MongoDB in the –dbpath flag.

So, after creating a directory to store the database, you can run the MongoDB server. The server represents the mongod application, which is located in the bin folder. To do this let’s run the command line (in Windows) or the console in Linux and enter the corresponding commands there. For Windows it will look like this:

you can run the MongoDB server

The command line will show us some service information, for example, that the server is running on localhost on port 27017.

And after a successful server start, we will be able to perform database operations through the mongo shell. This shell represents the file mongo.exe, which is located in the installation folder above. Let us run this file:

we will be able to perform database operations through the mongo shell

This is a console shell for communication with the server, through which you can manage your data. The second line of this shell is to connect to the mongod server.

Now let’s do some simple steps. Let’s enter the following commands in mongo and after each command-click on Enter:

use test
db.users.save( { name: "Tom" } ) .
db.users.find()

The first command to use the test shall set the test database as the one to be used. Even if there is no such database, it shall be created automatically. Further, db shall represent the current database, i.e. the test database. After db comes to the users – this is the collection, to which we then add a new object. If in SQL we need to create tables beforehand, then the MongoDB collection is created by itself if there are no such databases.

Using the db.users.save() method, the object { name: “Tom” } is added to the test database users collection. The description of the added object is defined in the format you may be familiar with if you have dealt with the JSON format. That is, in this case, the object has a single key “name”, which is matched with the value “Tom”. That is, we add a user with the name Tom.

If the object was successfully added, the console will print the result as a WriteResult expression({“nInserted” : 1 }).

And the third command db.users.find() displays all objects from the test database.

the console will print the result as a WriteResult expression

From the output, you can see that some obscure ObjectId field was added to the initial values of the object. As you remember, MongoDB uses the field _id as unique document identifiers. And in this case, ObjectId is the value for the _id identifier.

Installing MongoDB Drivers

Of course, we can also work through the mongo console by adding and displaying objects to the id. But we would also benefit from having mongoDB interact with our applications written in PHP, C++, C#, and other programming languages. And for that purpose, we will need special drivers.

Drivers for such programming languages as PHP, C++, C#, Java, Python, Perl, Ruby, Scala, etc. can be found on the official website at https://docs.mongodb.com/ecosystem/drivers/.

Further, considering the interaction of individual programming languages with MongoDB, we will take a closer look at installation and drivers and all the necessary configuration for specific programming languages.

How to Install MongoDB on Windows 10

 
Tags: , ,

MORE NEWS

 

Preamble​​NoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...

Preamble​​MongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...

5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...

The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...

Preamble​​MS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...

First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...

Preamble​​Atom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...

Preamble​​MongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...

FlexibilityOne of the most advertised features of MongoDB is its flexibility.  Flexibility, however, is a double-edged sword. More flexibility means more...

Preamble​​SQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...

Preamble​​Writing an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...

Preamble​​Oracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...

Preamble​​IBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...

  What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....

Preamble​​If you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...

Preamble​​Starting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...