New version of FreeBSD 14.0 x64
December 22, 2023
Updated December 22, 2023

How To Create Database and Collection in Mongodb?

Databases MongoDB


That installation guide covered topic of manage DBMS MongoDB, in that case we will consider creation of database and collection in the system. All operations will execute on the machine with Ubuntu. If you have distribution of another system which support systemd, that guide will suitable for you.

MongoDB represent non-conventional DBMS, due to architecture and model system. They represent document-oriented and NoSQL management system. Instead of SQL in the DBMS represent own language of manage, which remind object-oriented language for programming. All object is entity with dedicated hierarchy DB -> Collections -> Document. Let's consider how to create two of the hierarchy step!


For avoid problem with library package and older utility we have to update system packages through apt manager:

apt update && apt upgrade -y
Screenshot №1 — Update

At the end of process you can see result of entering command, make sure that main component was upgraded! Run MongoDB shell or connect via any else way to the DBMS:

Screenshot №2 — Mongosh

After login you can interact with DBMS, by using special command. If you have problem with log into the system, than try to check daemon for properly work:

systemctl status mongod

If you see dead process then try to start or restart daemon and check status again:

systemctl restart mongod
Screenshot №3 — Status

That have to help start system! At the first let's check existed database:

show dbs
List of DB
Screenshot №4 — List of DB

We can create own DB using implicit and explicit method, by the default we can type:

use gg
Create DB
Screenshot №5 — Create DB

Which gg it's DATABASE_NAME, if you have already exist db with the same name, than system turn you to that db entity. Always when we start work with DB we have to type use command with name of DB. If you forget which database you use type:


And than name of the db will be displayed. In that db file we can create collection, main concept of them is grouping united various of files by determine parameters. We will use command before:

Create collection
Screenshot №6 — Create collection

By that command we create collection and simultaneously in the one command create document with value. The ff that name collection, you can enter any else. And by the command we can make sure that command will created:

show collections

In the field of the DB you can create multiply of the collections and use them. In another part of the manage MongoDB we consider deletion, rename and various operations of manipulate data in the system. All of that instructions dedicated to community edition version, which used in the different company.

5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.