Get MongoDB installed and running on OS X.
- [Instructor] Let's start at the MongoDB Download page for the community server. Scroll down to see the installation options for the Macintosh. Here, there are instructions for installing with the Homebrew package manager, as well as a direct binary download. If you already have Homebrew or would like to use it, follow that link for the instructions. This will allow you to have an easy-to-maintain global installation. If you'd prefer to download the binary instead, click the green download button to get the TAR file.
After it's downloaded, click it to extract the file. The easiest way to get the items in your path is to copy them into your /usr/local/bin directory, so we'll do that. First, start the terminal. Change directories into your downloads directory. And you'll see the mongodb directory there. Change directory into the mongodb x86_64 and enter the bin directory, and you're now in the directory with all of the executables for the mongo server and client.
Mongo and mongod are the two things we're most interested in here, but we're going to go ahead and copy all of these files into your /usr/local/bin. You'll need to use sudo for this. Once you've done that, you need to create the database directory. Again, you'll need to use sudo for this. /data/db is the directory that mongo will look for to store its files in. However, since you used sudo for this, we need to open up the permissions so that your regular user can access this directory.
So sudo chmod 777 /data and then we'll do it for /data/db as well. Now that it's been created, you can go ahead and start the mongod server. It's not mongodb, it's mongod. And the way to remember that is that you're just starting the mongo demon. So now that it's started, let's open another terminal window with Command + N, and we can go ahead and run mongo.
It starts up, the shell. So we're going to go ahead and make sure that this is working by doing a simple command, db.users.insert and I'll just put ({"name":"Kirsten Hunter"}) And it says that's it inserted one. So now we have an up and running mongodb server, and we're ready to go.
Released
5/2/2017- Installing MongoDB for Windows and OS X
- Why Mongo?
- Document-oriented data
- Exploring the Mongo shell
- Importing data into the database
- Building an application in Node.js
- Tuning Mongo queries
- Aggregation
- Replication and sharding
Share this video
Embed this video
Video: Install MongoDB for OS X