[Solved] MongoDB Server & Shell mongodb is not recognized as an internal and external command Error
Feb 12, 2025
Get the full source code of application here:
Hi Join the official discord server to resolve doubts here:
https://discord.gg/cRnjhk6nzW
Visit my Online Free Media Tool Website
https://freemediatools.com/
Buy Premium Scripts and Apps Here:
https://procodestore.com/
Show More Show Less View Video Transcript
0:00
uh Hello friends welcome to this video
0:02
so in this video I will show you how to
0:04
fix this mongod command is not
0:06
recognized as an internal or external
0:09
command so mongodb if you are accessing
0:12
mongodb in the terminal and you are
0:14
seeing this message there are quite a
0:17
few reasons related to it I will show
0:19
you some fixes in this video the very
0:21
first thing we need to do uh you need to
0:23
install mongodb server and also the
0:26
shell as well where you can execute the
0:28
commands so I'm assuming that you have
0:30
installed it but if you haven't you then
0:33
you need to install some softwares first
0:35
of all first of all if you want a
0:37
graphical user interface related to
0:40
mongodb if you want to create tables see
0:42
the tables in a graphical user interface
0:45
and you need to install this mongodb
0:47
Compass which is a free software so you
0:50
can type on Google and click on the
0:53
download button it's very simple it's
0:56
called
0:57
as you can say DB compass
1:04
download so if you want the graphical
1:06
user interface you can simply download
1:08
this I've already downloaded mongodb
1:10
Compass it's very simple when you launch
1:13
this they show this connect
1:16
button and it is you can create
1:18
databases using gu GUI but if you want
1:21
to access it in the terminal you need a
1:24
another software which is mongodb shell
1:27
if you just type mongodb shell download
1:31
and then it will
1:33
actually re redirected to this web page
1:37
and here you can download This by
1:39
clicking the download button it's again
1:41
a exe file uh
1:59
mongod D which is the actual server of
2:03
mongodb if you are seeing this message
2:06
then we need to add the path in the
2:08
environment variable so just search here
2:09
environment variable and right here you
2:12
need to go to the global path variable
2:15
and here you need to edit this and add a
2:16
new path where the mongodb in
2:19
installed
2:21
so typically if you haven't change the
2:24
installation directory by default
2:26
mongodb is stored in the C directory and
2:28
then here you need to search for the
2:30
program files directory right here so
2:33
just need to go into this directory and
2:36
here you need to find out mongodb so by
2:39
default it will create a mongodb folder
2:41
right here you will see that mongodb and
2:44
here we need to go to the server so
2:48
there are two folders out there server
2:50
and shell so I individually downloaded
2:53
the server and shell and created this
2:55
folder and pasted these two folders so
2:59
one by by one we need to first of all
3:01
for the server we need to add
3:04
this go to the bin folder and then this
3:08
is your mongod D actual application so
3:11
here if you open the command line and
3:13
type the same command mongod
3:16
D you will see the command will be
3:19
successful but we want this command to
3:21
be globally recognized for this we just
3:24
need to copy this path and copy this
3:28
path right click it and then add add
3:29
this a new entry in the environment
3:32
variable path so just add this to the
3:34
path here and same thing we will do this
3:37
for the shell as well so there is a
3:40
second folder if you see which is shell
3:43
folder so go into this folder and go
3:45
into the B bin folder and this is your
3:48
mongodb shell so again if you open the
3:51
terminal here and type the command
3:54
shell so you will see it will get
3:56
connected here shell
4:00
so again we need to copy this
4:02
path and add this into the environment
4:05
variable so just paste it so as soon as
4:08
you paste it now click okay
4:11
okay and then you need to restart the
4:14
terminals again open the terminal right
4:16
here and now if you type here mongod D
4:19
you'll see the command will be
4:21
successful and same goes with
4:23
shell as well
4:25
so now if you only want to use the
4:27
mongodb on the terminal you don't want
4:30
this graphical user interface you can
4:32
close the connection right here click on
4:34
disconnect so now the connection is
4:36
disconnected you can close this and now
4:39
if you want to access shell you
4:41
will see this error if if I type the
4:44
same command
4:46
shell so Shel is successful but
4:50
now if you want to interact with the
4:52
database we first of all need to create
4:54
the connection for
4:58
mongod so this is actually creating a
5:00
error here because for starting this
5:03
mongodb server in the terminal we need
5:05
to create a database folder so just
5:08
inside any directory let me go to the C
5:10
directory and create a new folder which
5:12
is DB so here all the information will
5:15
be stored which whatever tables that you
5:18
will create databases that you will
5:19
create so just create a
5:21
c DB folder so you can create any folder
5:26
according to your name so I just created
5:27
this DB folder so now if I start this
5:30
mongod server I will just give this
5:33
location of the
5:34
folder so the command will look like
5:38
D and here you need to specify DB
5:42
path and here you need to give the full
5:44
path of that folder so it is located in
5:47
C drive and/ DB so you need to give path
5:51
in double codes so this is actually the
5:54
command here so just copy this command
5:56
and now enter it so now if you see the
5:59
connection will be successful so now you
6:02
need don't need to close this just open
6:05
this in one window and now open the
6:08
second terminal and now open the com
6:11
shell so just type shell so
6:14
here you can let's suppose I want to get
6:17
a list of all the
6:19
databases we can give a show command
6:22
here show databases so it will show you
6:25
all the databases that are there inside
6:27
your mongodb
6:29
and now you can even create a new
6:31
database by using the use command so
6:34
use followed by your database name so it
6:37
will be switched to that database then
6:40
you can create a collection or a table
6:44
like this all these commands are there
6:47
so the data will be inserted you will
6:50
see that it will get a response so if
6:52
you want to now show all the tables
6:55
which are there in this database so you
6:56
will say show Collections and then you
6:59
can find out the data so DB my
7:02
collection this is the name of the table
7:05
and we have the find
7:07
function so in this way the data will be
7:09
returned to you like this so this is a t
7:12
data stored in this table so or
7:14
collection so in this way I showed you
7:16
step by step how to get started or fix
7:19
that error and install shell and
7:21
use mongod DB inside your terminal so
7:24
mongodb server so thank you very much
7:27
for watching this video and also o visit
7:30
my website as well free mediat tools.com
7:32
uh which contains thousands of tools
7:34
regarding audio video and image and I
7:37
will be seeing you guys in the next
7:39
video
#Programming
