MongoDB Starting and Database Creation
2K views
Oct 24, 2024
MongoDB Starting and Database Creation
View Video Transcript
0:00
In this video we are discussing MongoDB starting and database creation
0:06
Now what is the command with the help of which we can initiate the MongoDB
0:11
So open up the command prompt for Windows or terminal for Linux and then type Mongo to
0:17
start the Mongo shell. So here you see we have shown you in the Linux environment
0:23
So dollar prompt is there. So here we have typed this Mongo and the Mongo has got started and here we are getting
0:29
the Mongo shell prompt. So, there is a greater than symbol. So, type Mongo to start the Mongo
0:35
shell and we have typed the Mongo command and respective shell has got obtained. This prompt
0:40
is indicating that the shell has got loaded. Now, in the Mongo shell, type use database name
0:49
So, whatever the database name you prefer? So that has to be written. So it will create a new
0:54
database and use it as the current database. So if the database is pre-agreacted, you know, you'd. So if the database is pre-agreacted
0:59
it will use that one. Otherwise, if the database is not pre-existing, it will create the database
1:04
and it will use it. So, here you see in the prompt we have written use new DB
1:10
So, this particular message will be displayed that is switched to DB, new DB. So now we
1:15
can use this particular database. Now we can go for different other commands execution on this
1:20
respective database. So I think it is better. Let us go for one practical demonstration to show
1:25
you that how this command is actually working. First we shall open one terminal. So control altered T a terminal has got opened now we shall go for pseudo service MongoDB and then start
1:45
It is asking for the password I given the password here So now the service has got started so I shall go for MongoDB I shall go for Mongo to get our shell so now
1:57
we shall go for show DBS so I want to see all the pre-existing databases we're
2:03
having admin config and local so three databases are there now let me create my own
2:10
database I shall go for use my database so that is my database so switch to db my database so if you go for db I can see that I'm
2:21
working with this my database but if I go for DBS then I'm finding that you will go
2:27
for show DBS rather so I'm finding that that my database is not coming here
2:32
because until and unless one database is having collection at least one collection
2:37
then until and unless the listing will not be coming under the show
2:43
show DBS so you see in the show DBS listing we're not getting this my database getting listed
2:49
so in this way we can create one database and we can switch to that immediately so if this
2:56
my database was pre-existing then obviously use my database will just switch to the database
3:03
but as in this case my database was not pre-existing so it has created and it has switched to this
3:10
my database DB so how to delete this one so let me also show you that one so I shall go for DB that is drop database method
3:23
so I shall go for that so in my database has got deleted so in this particular
3:28
demonstration we have shown you that how to create your own database and how to delete
3:33
that one and how to use that one thanks for watching this video
#Educational Software
#Programming
#Training & Certification