REQUEST COMPLIMENTARY SQLS*PLUS LICENCE
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:
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.
- 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:
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:
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.
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
MORE NEWS
PreambleNoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...
PreambleMongoDB 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...
PreambleMS 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...
PreambleAtom 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...
PreambleMongoDB 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...
PreambleSQLShell 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...
PreambleWriting 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...
PreambleOracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...
PreambleIBM 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....
PreambleIf 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...
PreambleStarting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...