MongoDB: Auth – Enable Authentication – Create Admin/Root User

By default, authentication is disabled in MongoDB, but this is not so critical as, out of the box, MongoDB is listening on localhost only.

If you are going to allow remote connections to MongoDB, then it is definitely needed to enable authentication.

In the following article i will show how to enable authentication in MongoDB and how to create admin and root users. (more…)

MongoDB: Create Database and User – Mongo Shell

In MongoDB, in the opposite to traditional SQL databases, there is no need, as well as possibility, to create an empty database.

To create a new database in MongoDB, it needs to insert at least one document into it.

In this article i will show how to create a new database and a user for this database in MongoDB from the command line, using mongo shell.

I will also show how to list collections, get all documents and delete a MongoBD database. (more…)

MongoDB: Allow Remote Access

Out of the box, MongoDB doesn’t allow remote connections, because by default it has no authentication enabled and is listening on localhost only.

If you try to connect to MongoDB without remote access being allowed, you will get this error:

Error: couldn’t connect to server $MongoDB:$Port, connection attempt failed:SocketException: Error connecting to $MongoDB:$Port :: caused by :: Connection refused … exception: connect failed

In this article i will show how to allow remote access to MongoDB. (more…)

MongoDB: Install Client – Mongo Shell – Ubuntu, CentOS

The MongoDB client, also known as mongo shell, is a command line interface to MongoDB.

The mongo shell is included in MongoDB package, but to connect to MongoDB it is enough to install MongoDB client only, without MongoDB itself.

From the following article you will find out how to install the latest (or specific) version of mongo shell on Ubuntu and CentOS. (more…)