Hey, did everyone they share your programming friend from YouTube?
And now let's continue the CDs of MongoDB.
Now, in case you are from the world of Windows operating system, I wanted to say two things to you.
First and foremost, videos for the installation of Windows is actually the next video.
So in case you are from feature, you can go there.
In case you are with the same timeline, make sure you hit that subscribe button so that you can know
when I'm uploading that video to tip number two is make sure you watch the installation for both Mac
and Windows and now Windows guys will say, Hey, why I want to watch the Windows one or the Mac one.
The point is, my dear friend, you never know on what system you'll be working, when you'll be working
for a company or maybe for a project.
Sometimes things change and it's very awkward situation that you don't know how to install the exact
same thing on which you call yourself an amazing master on a different operating system.
It should not be the case, so make sure you watch both the videos, just have a feel, maybe watch
it in two weeks and understand how things are installed here on the Mac environment.
If you are from Windows, if you're from Mac, obviously you have to watch it.
So let's go ahead and install this thing here.
And yes, you notice the new screen here in the wallpaper because the entire screen is new.
This is big, gigantic old screen died.
So let's go ahead and install that.
Now, in case you are thinking to go on to MongoDB slash download center and want to download this star
dot zip file.
No, please don't do that.
We have a better solution and better approach of installing things on a macintosh.
And I would like to introduce you one thing which in case you are a developer, you might be already
aware of it.
So it is known as Blue Dot.
Now Blue is a service which is package manager and they call it proudly as the missing package manager
of Mac OS just like we have yum and apt get exactly similar to that.
So this video can be helpful for all those people who are on the Linux environment as well because the
problems are exactly the same as on Mac as on Linux.
It's not that much problematic.
By the way.
The first thing you have to do is copy this and this entire line and this is the way how you install
Bru on your system.
Now open up your terminal.
We can just zoom it a little bit and this is terminal just hit command space type terminal and this
is the one just paste it up there and it's going to install the bru mine is already installed.
That's why it says, hey, we don't want to do that again and probably want to update some things and
stuff like that.
Mine brew is already very up to date, I believe so.
In case it wants to take some time, we definitely want to give it that time, make sure it's all updated
and all these things.
And there we go.
It's all done very quickly.
So this is the step number one.
In case you are making the notes, the step number two is optional, but I highly recommend you to do
so.
We are going to use Node in the very far from in the cities.
We will be using mocha and mocha works really fine with the Node.js.
So now we would like to install Node GSI.
I highly recommend to follow me along here and we can ask the Bru to install it for us.
So we are going to say brew install and we can just say node.
Now this is going to install almost the latest version for us.
You can just hit enter.
I believe Node is already installed on my system and it said yes, brew is already node is already installed.
In case yours is not installed, just go ahead and let it do its thing in case you want to check the
node version.
That is all fine and mine is ten .5.0.
In case you are watching from future, you might be having latest version than this one.
That is fine, my dear friend.
You don't need to do exact same version as long as you are having somewhere around like more than five
version of the node.
That is also totally fine.
Okay, that's very stable.
Okay.
Now it comes to installing the hero of the video, which is brew, brew, brew, install, and we want
to install Mongo.
Now, it's not MongoDB, it's just Mongo.
Now this is going to take some while to just download and install all these things indirectly.
Just visit the GitHub of that or probably wherever the repositories are and just gathers it and install
it on the system.
The problem is not the installation problem is what comes after the installation, the configuration
part of the node.
So don't worry, I will be walking you through with the configuration part.
Actually, there are two errors that we have to face in order to properly understand where we are lagging
it.
So we're going to face both the errors.
I'm going to manually fall into that error and we'll show you how you can come back from those errors.
So I guess it's going to take a little bit while.
And what I can do is I can hit a quick pause on this video so that that magic video editing can happen.
And you don't have to see this bar just filling up till 100.
So now that MongoDB is installed and you might have seen these things, MongoDB, whenever we install
any kind of server on a Linux, whether that's RedHat one or anything as a given fact, they always
are run using these d ds.
This D actually means daemon and yes, it exactly spells the same as daemon from any horror movie,
by the way.
So we have to start this MongoDB Daemon server.
So let me hit control l first of all, so that I can clean my screen and I'm going to fall into my very
first error.
So hit the mongo dx to start the demon and we are going to see some errors.
Now, this is a classic error of MongoDB.
I hope I can see some of the things here and can mention what exactly is the problem.
Otherwise, I have to tell you.
So I guess they are not able.
There we go.
This is this is really hard to find.
This is exactly the reason of the very first error.
Whenever you install the MongoDB on a Linux or on a mac, it just looks up for a default data directory.
Here in our system, the default directory is not ever present.
Whether that's a flavor of debian ubuntu, any given flavor of the Linux Mac including.
So we have to create this directory and we're going to solve our very first issue, but we are going
to fall into the next one.
So how we can do that, it's actually really simple.
We're going to create a directory, make sure you use the sudo command because it requires administrative
purposes, administrative privileges here.
And we're going to use a shortcut of hyphen B here.
So we're going to say slash data, slash DB.
Now make sure make sure this is warning, make sure the slash is there before the data.
If you are not going to be putting a slash here, that means you are doing absolutely wrong.
I know even after telling this one, so many people will in the comments will be saying it.
So make sure you hit the slash data slash DB and I'm going to hit enter it sometime.
Asks a password, but I guess it's not asking me.
I guess the p command is not recognized here.
I guess it's the capital p.
My bad.
There we go.
So we're going to hit the cooler.
There we go.
So sudo okay.
My bad.
I forgot the main command which is my dear.
Come on.
That was unacceptable.
Mkdir to make a directory and hopefully now we have a data directory.
My bad.
Totally my bad.
I wanted to create a directory.
Okay.
We don't need to verify that.
I believe it has done its task.
So there we go.
So the directory is done.
So now we are expecting to run this MongoDB command, but it's going to still fall into one mode error
one or one more gotchas.
There we go.
And I hope I will be able to show you the error again.
It says again, this error is still here.
But actually the problem is not this one, because we can see that the directory is there to confirm
it.
We can just do a CD slash and I can write D A and hit the tab.
That means data is there.
If I had the tab again we can see that the DB is here.
So the problem is not the directory.
If I can see that it is really hard to find that error again.
And there we go.
It says attempted to create a log file on a read only directory and the directory is there, but it's
still terminating.
So this is a classic problem of the privileges are also known as permissions.
What I mean by that you have created that.
But in the Linux system there are so many permissions we have to figure it out as well.
So follow this command here.
Again, it's actually really, really simple to change the permissions.
I will not forget the operation command again.
So we're going to do a pseudo.
We want to change the ownership of that.
So it's command is C, o, w n and to whom we want to give the permission.
That's also an interesting question.
In order to answer that, first, we have to ask the system, who am I right now?
So if I say, who am I?
My system name is Studio.
That's my computer name and you will get your name a little bit different.
So make sure you get that first and then we can use Sudo and change the ownership of that directory.
We're going to use the shortcut commands of R and V and now we're going to write the name of our computer,
whatever.
Who am I?
Return us back and now we're going to change the permission of data slash DB.
So both of them, I want to change it.
There we go.
Now, finally we can run the mongo dx here Mongo dx and hit that enter.
Now you're going to see a lot of things here, but these are not error.
This is how server runs and we cannot verify it right now.
We will be doing it verification a little bit later, but as long as you get something like this, it
is all good and it is all working.
What we can do is we can just go and open up the new terminal.
So I'm going to just hit the shell and a new tab and there we go.
We got a new tab here and I can run a simple mongo here.
Mongo.
Go and hit enter.
As long as you get this ticky arrow thing, that means your mango is working.
Good.
Make sure you open this into the new terminal.
Not in this one, because this needs to keep up and running whenever we want to go.
That if you're getting this one here, that means everything is awesome and fine.
But here are a couple of gotchas for you for the future as well.
Now.
MongoDB We have installed it as a service.
Our database is running as a service whenever we want to work with it.
This service should be up and running.
So there are a couple of options.
The first one is a little bit not so good, which is every time you want to watch my tutorials or want
to work with the MongoDB, just come up and write MongoDB on the terminal, leave it up and running
all the time.
You want to work it and just open up another shell where you just want to work or do whatever you want
to do.
So this is not so good approach because I know many times you'll be forgetting to, uh, and starting
this mongo daemon here and will be complaining.
Hey, my code is not working.
Not a good approach.
Not a good approach, honestly.
So we're going to hit the control.
See here to quit the this mongo here.
I'm going to hit control.
See to close down this here as well so that we can work on a different solution here.
So we have shut down the MongoDB for a moment here.
Now type this command along with me.
These are something which is related to brew.
So what I want you to do is brew services, start mongo, okay, and hit the enter one.
It's not going to do much.
It's going to just do a few fancy stuff.
What it is doing, it is installing MongoDB on your system as a default service.
What it will do whenever the next time you'll restart your computer automatically a mongo service is
going to be running on your computer again after you restart your computer next time when you come up.
You don't need to do MongoDB on the one terminal and then Mongo on to another terminal.
You don't need to do that if you have run this command.
Otherwise, in case you don't want to use that bunch of resources, you can just use the previous method.
Hit the MongoDB on the terminal and on the next one just go ahead to the regular mongo stuff.
Again, restart is compulsory here.
Okay.
So this was a quick installation of mongo on a macintosh as well as the same thing works on your ubuntu,
on your linux.
All the flavors of that because it is exactly the same there.
We don't have bru we have apt get and yum in case whatever the flavor of linux you are installing and
working on it.
So that's it for this video in case you are new here, make sure you hit that subscribe button, you
know the regular stuff stuff blah blah blah.
I subscribe and all of that.
In case you are on a Windows World, make sure you watch the next video where we're going to install
the MongoDB on a Windows environment.
That's it.
And I'm going to catch you up in the next video.