Eve: Building RESTful APIs with MongoDB and Flask Transcripts
Chapter: Appendix: Installing MongoDB
Lecture: Setting up MongoDB on macOS

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Here we are on a relatively new Mac, you can see that this is MacOS seirra, so relatively new, and if I come over here and I type Mongo,
0:11 no there is no MongoDB installed here. So what are we going to do— we're going to install and set up MongoDB,
0:18 so those of you who use MacOS, like I do, you'll see that this is actually the easiest of all the various operating systems to set up. Let's do it.
0:26 So we're actually going to start out at Homebrew, now you may have Homebrew installed which is awesome,
0:33 and you can just run brew update, but if you don't then you're going to need to run this command; so we're going to run a script pass it off the ruby,
0:41 this is going to install Homebrew and if I hit enter, it's going to go do this, this one time it needs my password
0:47 to make changes to the system, but in general, you should not sudo run Homebrew, it even warns you if you do that I believe.
1:01 Okay, I get the little ding, it looks like everything is all set up. So now if I type brew, yeey, stuff happens.
1:08 So the next thing that I want to do is actually install MongoDB, so brew install mongodb,
1:22 and just like that, after 15 seconds, 20 seconds something to this effect, it says MongoDB is all set up.
1:29 Now before I clear this and just run it, notice there's a couple of things, it tells us right away, right here how we get started,
1:35 we can either run MongoDB as a service, and if I do this without sudo, it's going to run this as a service any time I log in,
1:43 if I do it with sudo, it's going to basically do this as part of the machine startup, shut down, or I can just run MongoDB like so.
1:50 So let's go ahead and set this as a service, it takes a moment and now it's up and running. So how do we know whether it's running?
2:02 Well first of all, if I type mongo, it has something there, it has an app there right you can see 3.4.4 is the one at the time of this recording,
2:09 and now it's connected and there's a few warnings here about access control, this is worth considering, if this was a production machine
2:17 I would be quite concerned about this, it's my developer machine, so I'm not. Let me show you why I'm not.
2:25 Okay, so if we exit out of here, the other way that we could run MongoDB it's already running, so this isn't going to work again,
2:32 but we could run it passing this config file, but what's interesting is, check out this config file
2:37 so if we go look at that, it has just a few things for us, it tells us where the log file is going, good for system services,
2:44 where the data is going, and most importantly, it's listening only one local host, 127.0.0.1.
2:54 I don't know what my public ip address is or I have both the ipv6 and ipv4, MongoDB is not listening to either of them,
3:01 moreover, I also have my firewall turned on as much as possible, believe it or not, it is not turned on on MacOS by default
3:09 that is super, super suspicious to me. But anyway, firewall's on, and we're not even listening on the public network interface.
3:16 So do not change that, make sure that you are listening on only local host
3:21 or that authentication warning, that's going to have a whole different meaning.
3:24 When we get to the actual deployment section, where we deploy to production we're going to set up users, we're going to set up ssl,
3:30 we're going to set up authentication, all of those kinds of things, among others, but for now, for the devmachine, I think listening on local host
3:37 is probably sufficient for what we're doing. So this MacOS is ready to take the class.
3:44 The other things we would need to do, is install PyCharm, install RoboMongo, and do we have Python 3— we do, we have Python 3 installed,
3:54 I believe I actually already installed that earlier on this virtual machine. So you're going to want to make sure you have Python 3 installed,
4:01 RoboMongo, and PyCharm, they all have super simple installers that's basically either drag and drop or double click
4:07 and follow the next button and you'll be all done. Then the machine will be completely ready to take this class.


Talk Python's Mastodon Michael Kennedy's Mastodon