How to Install MongoDB on Mac | Install MongoDB on macOS (2024)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video I'm going to show you how you can download and install mongod DB on your Mac operating system I'm also going to show you how you can start your mongodb server and use it with mongodb client so let's get started and let's see how we can do it so first of all let's try to download the mongodb community server so for that just open your favorite browser and search for mongodb and the first link which will appear here will be from mongod db.com I'm going to click on this link which is going to redirect me to the mongodb web page now here you will be able to see uh this kind of menu we are going to click on the products section and then we are going to choose this section which says Community addition so let's click on the Community Edition option and now on this page you will see mongod DB Community server download and when you scroll down a little you will be able to see the select package option under the Community server option so we going to just select this option so just click on select package option which is going to open the version platform and the package type right so the version at the time of making this video is 7.0.4 which is the latest version now for Mac OS you have two different versions one is the Mac OS ARM version and other is Mac OS x64 version I have Mac OS M2 processor so I can choose Mac OS arm 64 if you have Intel version you can choose the Mac x64 without arm and the package is tgz package let me click on the download button which is going to start the download of this uh tgz file and once this TG Z file download so I'm going to click on this TG Z file and then it's going to extract this TG Z file into a directory which is mongod DB Mac OS Arc 64 so now what we are going to do is we are going to transfer this mongod DB folder into our home folder of our Mac operating system so for that we need to open the terminal so I'm going to first of all go to the spotlight and then search for terminal here and then click on Terminal which is going to open the terminal so when terminal opens it opens in the home directory and here we want to copy our uh mongodb folder right so when you do PWD you will see the full path of your home folder which is for/ users for/ code bind in my case it can be different name in your case just remember this uh path now I'm going to CD into the downloads folder so here is the folder which we have extracted so now we need to move this folder into this folder which is our home directory so just write MV space the name of your mongodb folder which is mongod DB Mac OS AR 64 hyphen 7.0.4 in my case we want to copy this folder to our home folder which is this one right so just type this path here or you can just write for/ user for/ whatever is your username okay once you are done you can press enter so basically we want to move this folder from the downloads folder to our home folder let me just press enter and now I can first of all type CD which is going to redirect us to the home folder once again and then when I do PWD you can see I am in my home folder and here when I do LS hyphen Al I will be able to see the mongod DB folder here also so here is this folder you can see so let me clear the terminal now so here you have your mongod DB folder now in order to run your mongod DB you need to go inside the mongod DB folder so let me go inside the mongod DB folder and here I have this bin folder so let me CD into the bin bin folder and in the bin folder when I do LS I will be able to see few binary files which are mongod D and mongos so first of all we are going to copy this bin path into our zshrc directory because otherwise our terminal is not going to recognize the mongod DB path so when I do CD we are in our home folder once again and if I give mongod D command and then press enter it doesn't recognizes this uh command because we haven't set the path for this binary for mongod DB so what we need to do here is when I do LS space hyphen Al here there will be a zshrc file in your home directory and here we need to set uh the path of if this file is not present you need to create this file using the touch command so just write touch and then do zshrc and it's going to create your uh zshrc file if it already is present then you just need to open this file to open the do zshrc file you can use open command and then write do zshrc and then press enter in my case this file is already present because I have already added some export paths and I need to add the mongod DB path here also so to add the mongod DB path first of all let's open the spotlight so here just type for slash user with capital u so we are going to click on the users folder under folders results so just click on this and then click on uh your username in my case it's code bind and then click on the mongod DB uh folder so in my case uh this is the name of mongodb folder and then click on the bin folder so you need to copy the folder path of this uh directory so to copy the path what you can do you can open uh this bin folder in the finder and then click on view and then click on show path bar and it's going to show this directory in the path bar so right click here and then click on copy bin as path name which is going to copy the path of this Direct tree let's paste this path here and then what you need to do before this just write export space Capital path is equal to and in curly brackets path and then write colon and then your path which is for/ users code bind in my case and then the path to your mongodb bin directory I need to use the small e here instead of capital E so that uh it works fine and once you are done just press command s to save this and then close this uh text edit and once that's done you need to write this command which is Source space. zshrc in your home directory right press enter once that's done let me clear the terminal and then it mongod D command is going to work so just typee D and then press enter now mongod D command is working right now but in between it's going to uh throw an error and the error will be related to this uh directory which says for SL data/ DB path will not be found so we need to create the data path of uh your data directory so now we are going to create the data directory in our home folder so I'm in my home folder I can do PWD and you can see in I'm in my home folder here I'm going to create a directory so I'm going to just write Pudo and then I'm going to give this mkdir command and then hyphen p and then just write data SL DB okay so press enter which is going to create this data/ DB directory in your or uh home folder I can do LS and I can see this data directory is created and when I go into the data directory CD into Data I can see this DB directory right so once this uh directory is uh created I'm going to just uh clear the terminal and then I just need to run the mongod D command with the data directory path so you need to give this command in order to Run mongod demon or mongod D so just give mongod D and then hyphen hyphen DB path is equal to for/ user for/ your username in my case my username is code bind if you don't know your username then uh you can open uh a new terminal window and then just write PWD and whatever comes after users folder that is your username right so just write mongod dpace hyphen hyphen DB path is equal to/ users for slash your username slash data/ DB this is the path which we have created right now and then press enter and now it gives me the error and the the error says I don't have permission to create the general d right so instead of uh this I need to run this command with the pseudo privileges so instead of uh this just add suda in front of uh your command and when it asks for your password just provide your password and once you do that your mongod def server is finally uh started right all the things I'm going to give you in the description of this video all these commands so you don't forget anything so now our mongod Deon is running but how you can connect to uh your mongod DB server using a client so when you download mongod DB it only comes with the mongod DB server it doesn't come with mongodb shell or mongodb uh Compass which is the graphical user interface utility so let's download them one by one also so once again go to your favorite browser and search for mongodb then click on the mongod db.com result then click on products here and then click on Community Edition here under Tools you will see shell and DB Compass first of all let's uh download the mongod DB Compass which is a GUI application so I'm going to select this and then when I scroll down I can see the version form will be Mac OS arm 64 M1 for me because I'm using Apple silicon processor if you're using Intel choose the other version and then the package will be DMG click on download which is going to start the download of this DMG G file and once this DMG file is downloaded let me click on this and it's going to start this mongod DB Compass installer so the installation is simple you need to drag and drop this mongodb compass into your applications folder select mongodb Compass press command key and then drag and drop this icon on top of the applications folder which is going to copy this uh mongod DB compass in your applications once that's done go to to your Launchpad and you will see mongod DB Compass here click on it and it's going to start the mongod DB Compass now keep in mind I have this mongod demon running so I haven't cancelled this command so mongod demon is running in my case don't close this terminal otherwise mongod demon will close right so you can see this mongod demon is still running and then in uh the mongod DB compass this is the connection string to connect to your local host mongod DB server instance so just leave it as default and then click on connect which is going to connect to your mongodb server instance and you can see by default you have this admin config and local databases by default present in your mongodb servers so now you are connected to your uh mongodb server successfully using mongodb Compass you can also create a new database click on create database and then name your database for example demo you can also create a collection name for example names and then you can also choose if it's a Time series database I don't want this right now and then click on create database and it's going to create this demo database with this um collection which is called names so everything is working fine now you can also use m sh you can see this option here and it's for sh and you can use this command line tool to interact with your mongodb uh server using the command utility so I'm going to just say show DBS here which is going to show me the list of all the databases so when I press enter it's going to show me the list of all the databases the demo database I have created so you can see it shows me the demo database if I want to uh work with particular database I can use uh use command so use and then use demo I want to use the demo database and then press enter so I'm switched into the demo database then I can just say show Collections and you can see it's autoc complete right so when I press Tab It Auto completes my command and it shows me the collection so you can use this sh to uh use command line uh client with your mongod DB server if you are a fan of kui just use this one so after installing mongod DB Compass you will not even need the shell utility separately because this sh interface is already there but if you want to install shell separately without compass then you can go to shell under Tools and then download this zip file and then use command to uh interact with your mongod DB servers so that's it for this video this is how you can download and install mongod DB on your Mac operating system I hope you've enjoyed this video and I will see you in the next video
Info
Channel: ProgrammingKnowledge
Views: 41,901
Rating: undefined out of 5
Keywords: MongoDB, Database, Open Source database, NoSql, Installing MongoDB, MongoDB Tutorial for Beginners, Mongodb, Advantages, Data Modelling, Drop Database, install MongoDB, How to install MongoDB, MongoD, databases, server, Ubuntu LTS, How do I install MongoDB on my Mac?, How do I know where MongoDB is installed on my Mac?, how to install mongodb on mac 2024, brew install mongodb, mongodb compass, mongodb mac, install mongodb mac m1, mongodb download, mongodb compass mac
Id: 8gUQL2zlpvI
Channel Id: undefined
Length: 15min 47sec (947 seconds)
Published: Fri Jan 12 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.