Full-Stack Web Development with Vue.js and Node

(singke) #1
Introducing MEVN Chapter 1

Installing MongoDB via Homebrew

To install MongoDB in macOS from Homebrew, follow these steps:



  1. With Homebrew, we just need a single command to install MongoDB:


$ brew install mongodb


  1. Create a directory that will be used by Mongo to save data:


$ sudo mkdir -p /data/db


  1. Start the Mongo server:


$ ~/mongodb/bin/mongod

Hence, MongoDB is finally installed.


Installing MongoDB on Linux


There are two ways to install MongoDB on Linux as well: we can either use the apt-get


command or we can download the tarball and extract it.


Installing MongoDB using apt-get

To install MongoDB using apt-get, perform the following steps:



  1. Run the following command to install the latest version of MongoDB:


$ sudo apt-get install -y mongodb-org


  1. Verify if mongod has been successfully installed by running the command:


$ cd /var/log/mongodb/mongod.log


  1. To start the mongod process, execute the following command in the Terminal:


$ sudo service mongod start


  1. See if the log file has a line that denotes that the MongoDB connection was made
    successfully:


$ [initandlisten] waiting for connections on port
<port>
Free download pdf