1 00:00:00,240 --> 00:00:06,060 In this video you're going to install Mongo D.B. on your machine that's going to allow you to actually 2 00:00:06,060 --> 00:00:11,190 start up the Mongo DB server and connect to it from node j s. 3 00:00:11,250 --> 00:00:16,170 Now this video is for Mac and Linux users only if you're on Windows. 4 00:00:16,170 --> 00:00:19,640 I've created a separate installation video for you. 5 00:00:19,680 --> 00:00:25,840 That's the next one so you can stop watching now and jump over to the next video if you're on Windows. 6 00:00:25,860 --> 00:00:31,080 If you're still watching this one I'm gonna assume you're running on either mac or linux and we're gonna 7 00:00:31,110 --> 00:00:33,450 work through the installation process. 8 00:00:33,450 --> 00:00:38,490 You can grab mango D.B. by heading over to get mango D.B. now from here. 9 00:00:38,490 --> 00:00:41,070 There are a lot of different things we can download. 10 00:00:41,070 --> 00:00:44,160 We have cloud options server and tools. 11 00:00:44,160 --> 00:00:49,620 We want to grab a server that we can actually run on our machine and there are two options here. 12 00:00:49,650 --> 00:00:55,380 The community server or the enterprise server we're gonna be using the community server which is the 13 00:00:55,380 --> 00:00:57,440 free version of Mongo D.B.. 14 00:00:57,510 --> 00:01:02,340 We'll be able to get up and running on our machines down below before we can download. 15 00:01:02,340 --> 00:01:08,190 There are three things we can pick version OS and package now right here. 16 00:01:08,190 --> 00:01:13,160 You want to pick the current release even if that's greater than what you're seeing for me. 17 00:01:13,170 --> 00:01:17,480 So the current release right now is four point zero point four. 18 00:01:17,520 --> 00:01:23,310 If you're seeing a more current release you want to grab that as I'll be updating the videos to account 19 00:01:23,340 --> 00:01:24,990 for any changes. 20 00:01:24,990 --> 00:01:26,730 Next up is the OS. 21 00:01:26,730 --> 00:01:33,810 So for Mac users you want to stick with Mac OS and do you want to grab the T GC archive of all of the 22 00:01:33,810 --> 00:01:35,890 Mongo D.B. files. 23 00:01:35,970 --> 00:01:38,880 If you're running on Linux you want to change the OS. 24 00:01:38,910 --> 00:01:42,480 You can see a bunch of different distributions listed here. 25 00:01:42,480 --> 00:01:48,270 So as an example if you were running on the latest a boon to eighteen point zero or you could grab that 26 00:01:48,270 --> 00:01:50,810 here then you can pick your package. 27 00:01:50,910 --> 00:01:58,620 Now for Mac the only option you had was the GC archive for a boon to an other Linux distributions. 28 00:01:58,650 --> 00:02:00,360 You're gonna have other options. 29 00:02:00,360 --> 00:02:05,400 You want to switch that over to teh GC to get everything working correctly. 30 00:02:05,400 --> 00:02:06,380 So if you're on Linux. 31 00:02:06,390 --> 00:02:07,700 This is what you want. 32 00:02:07,770 --> 00:02:12,570 I'm going to switch over to Mac to actually grab the archive for myself. 33 00:02:12,630 --> 00:02:15,160 I don't have Mongo DB installed. 34 00:02:15,180 --> 00:02:20,640 We're going to work through the process together as it's a more manual setup then something like no 35 00:02:20,640 --> 00:02:27,390 JSA where we have a nice wizard the installer walks us through all the steps with Mongo D.B.. 36 00:02:27,390 --> 00:02:32,610 There's a little manual work that needs to be done to get everything up and running once the download 37 00:02:32,610 --> 00:02:33,380 is complete. 38 00:02:33,390 --> 00:02:39,690 You want to go ahead and crack open the finder on Mac or your file explorer on Linux and navigate over 39 00:02:39,690 --> 00:02:41,720 to the downloads directory. 40 00:02:41,730 --> 00:02:46,640 Here we have our archive and I can double click that to extract its contents. 41 00:02:46,740 --> 00:02:51,830 What's inside of there is what we need it to actually manage our Mongo DB server. 42 00:02:51,830 --> 00:02:58,290 So in here we have they been directory the bin directory contains a bunch of executable is which we 43 00:02:58,290 --> 00:03:01,510 can use to perform various tasks. 44 00:03:01,530 --> 00:03:07,810 The main one is Mongo DB which we can use to start up the Mongo database server. 45 00:03:08,000 --> 00:03:13,860 So before we actually run this executable we want to take this directory and move it to a more permanent 46 00:03:13,860 --> 00:03:15,570 place on our machines. 47 00:03:15,570 --> 00:03:20,910 I don't know about you but for me the downloads folder is basically a temporary directory that gets 48 00:03:20,910 --> 00:03:23,200 deleted every few days or so. 49 00:03:23,250 --> 00:03:26,650 So we want to move this to a place where it can live long term. 50 00:03:26,790 --> 00:03:30,440 Before I move it I'm going to update the name of this directory. 51 00:03:30,480 --> 00:03:34,650 Right now it contains a lot of additional unnecessary information. 52 00:03:34,650 --> 00:03:40,800 All I'm going to do is rename this folder from what it currently is just over to something simple like 53 00:03:40,800 --> 00:03:42,770 Bongo D B. 54 00:03:42,810 --> 00:03:48,150 Now from here what we want to do is put this somewhere permanent and a great place to put it is the 55 00:03:48,180 --> 00:03:50,070 user folder on your machine. 56 00:03:50,070 --> 00:03:52,740 I'm gonna crack open another finder window. 57 00:03:52,830 --> 00:03:59,520 I'll navigate over to the user directory and from here I'm going to take that Mongo DB folder move it 58 00:03:59,520 --> 00:04:04,290 out of the downloads directory and move it into its more permanent location. 59 00:04:04,290 --> 00:04:07,680 Now once it's over here we're almost ready to start up the server. 60 00:04:07,680 --> 00:04:12,060 The next thing we need to do is create a place for our data to be stored. 61 00:04:12,060 --> 00:04:18,220 Now by default Mongo D.B. expects you to create a data directory at the root of your hard drive and 62 00:04:18,240 --> 00:04:21,180 in there it expects a D.B. directory. 63 00:04:21,180 --> 00:04:26,270 That's not ideal for many users as you're going to run into a ton of different permissions errors. 64 00:04:26,310 --> 00:04:31,850 It's much better to create a directory inside of your user folder to store the data. 65 00:04:31,860 --> 00:04:38,460 So right here I'm going to create a new directory in the same folder where I have Mongo D.B. and I'll 66 00:04:38,460 --> 00:04:42,540 call this Mongo D.B. hyphen data. 67 00:04:42,540 --> 00:04:48,450 So I have Mongo D.B. which contains the executable is necessary to actually start things up and manage 68 00:04:48,450 --> 00:04:54,840 our database and they have Mongo D.B. hyphen data which is currently empty but which will shortly start 69 00:04:54,840 --> 00:04:57,550 to contain our databases data. 70 00:04:57,840 --> 00:05:03,000 Now that we have both of these in place we're ready to actually start up the database and we do that 71 00:05:03,000 --> 00:05:05,930 by running a single command from the terminal. 72 00:05:06,030 --> 00:05:12,660 For me I'm going to navigate back over to visual studio code and from the terminal we are going to run 73 00:05:12,690 --> 00:05:15,680 one of the executable is in that bin directory. 74 00:05:15,690 --> 00:05:20,940 Now if you put the directory somewhere else on your machine your command is going to look a bit different. 75 00:05:20,970 --> 00:05:24,120 To start we need to get the path to our user directory. 76 00:05:24,120 --> 00:05:26,920 Now if you already know that you can simply type it out. 77 00:05:27,030 --> 00:05:33,750 If you don't know it you can run C.D. space tilled up to navigate to your user folder and from there 78 00:05:33,810 --> 00:05:39,650 you can use it p WD to print the current working directory when you run that command. 79 00:05:39,660 --> 00:05:41,400 It's going to spit out a path. 80 00:05:41,520 --> 00:05:47,280 And this is something we're going to use in the command to start up Mongo D.B. so to kick things off 81 00:05:47,280 --> 00:05:49,890 we have to list out the path to the executable. 82 00:05:49,890 --> 00:05:57,240 So for me it is forward slash users forward slash Andrew which is exactly what I got right here. 83 00:05:57,240 --> 00:06:02,280 Then forward slash Mongo D.B. which is the name I picked for my directory. 84 00:06:02,280 --> 00:06:06,550 Forward slash bean forward slash Mongo D. 85 00:06:06,630 --> 00:06:13,590 Then we use the D.B. path argument to provide a path to that data folder we created. 86 00:06:13,800 --> 00:06:18,720 So that would be once again forward slash users forward slash Andrew. 87 00:06:18,840 --> 00:06:22,760 Then forward slash Mongo D.B. hyphen data. 88 00:06:23,220 --> 00:06:25,670 So this is the complete command for me. 89 00:06:25,680 --> 00:06:31,260 Make sure to just swap out the beginning portion with whatever you got from TWD when you were running 90 00:06:31,260 --> 00:06:33,930 that command from your user folder. 91 00:06:33,930 --> 00:06:39,540 Now when I kick this off we're gonna get a ton of output as it initialize is the database and gets the 92 00:06:39,570 --> 00:06:41,220 database up and running. 93 00:06:41,220 --> 00:06:43,750 Right here I'll hit enter to run the command. 94 00:06:43,830 --> 00:06:49,890 We have all sorts of output as it starts itself up and we can see that after all of that happens it's 95 00:06:49,890 --> 00:06:51,700 just sitting and waiting. 96 00:06:51,720 --> 00:06:57,390 The server is up and running and now it's waiting for connections to the database where the connector 97 00:06:57,420 --> 00:07:04,080 can read and write from the database adding documents querying documents updating documents or deleting 98 00:07:04,080 --> 00:07:04,940 them. 99 00:07:04,950 --> 00:07:11,700 Now if we go back over to the finder we can see the Mongo DB data directory now has a ton of information 100 00:07:11,700 --> 00:07:13,040 inside of there. 101 00:07:13,050 --> 00:07:15,300 This is all just to initialize things. 102 00:07:15,300 --> 00:07:22,350 There are no actual documents as we haven't created any just yet but we now do indeed have the server 103 00:07:22,500 --> 00:07:28,080 downloaded on our machine and we know the command we can use to get the server up and running. 104 00:07:28,080 --> 00:07:33,230 One thing worth pointing out from the output comes maybe 8 or so lines before the end. 105 00:07:33,240 --> 00:07:40,020 Right here we have the following message waiting for connections on Pt. 2 7 0 1 7. 106 00:07:40,020 --> 00:07:43,890 This is letting you know that your Mongo DB database is up and running. 107 00:07:44,130 --> 00:07:48,300 And this is just the default port that Mongo D.B. uses. 108 00:07:48,300 --> 00:07:53,790 Now that the database is up and running you can connect to it from node J.S. to start reading and writing 109 00:07:53,790 --> 00:07:54,610 data. 110 00:07:54,630 --> 00:08:01,290 Now the next video is the Mongo DB installation video for Windows users so you can skip that and move 111 00:08:01,290 --> 00:08:06,330 on to the following video which is the video where you'll actually connect from node. 112 00:08:06,330 --> 00:08:07,500 I'm excited to get to it. 113 00:08:07,590 --> 00:08:09,690 So stay tuned and I'll see you soon.