How to install MongoDB the easiest way possible in NodeJS using Windows 10
First, what is MongoDB? MongoDB is an open source data base management system, it supports non-relational database technologies and is used in multiple web projects.
While trying to install MongoDB you will encounter several problems related with folder installation and components, if you are lucky enough you will not face that, but we tested in many computers and they face the same error.
If you follow the same steps as the MongoDB installation guide you will reach the point in which you are going to ask why it takes so long to end the installation, but in this tutorial, we are going to start from 0.
- Download your preferred version of MongoDB here.
- After downloading MongoDB, you should accept the terms and conditions.
-Now we need to select our type of installation, we can select custom if you want to select another installation folder, or complete install.
-In folder selection, if you want a fast installation and without problems, select the route that Mongo specifies, because if you select another one you will encounter problems or longer installation times.
-After your selection of installation of Mongo as a local service or network service, the installer will ask you to select if you want to install Mongo Compass, this is the important step, you should deselect MongoDB Compass, because this causes tons of installation time and it is not a necessary component for Mongo to work correctly.
- After installing MongoDB, we now need to go to our MongoDB installation folder in CMD, the route is C:\Program Files\MongoDB\Server\4.0\bin, we must initialize our CMD with admin privileges.
-We must now write the following lines for MongoDB to be completely installed, we are specifying routes for MongoDB.
mongod — directoryperdb — dbpath “Your/path/to/data/db” — logpath “your/path/to/log/file.log” — logappend –install
-Now we can use MongoDB by just writing in the current directory “mongo”
We now need to go to our project folder to install Mongoose.
— — What is Mongoose?
- Mongoose is Object Data Modeling (ODM) library for MongoDB and Node.js, we need it to connect MongoDB with our project.
- Now we can use MongoDB in our project, we just need to define our DB in our App.js and that´s it.
- ¿What if I want to install all MongoDB components?
o You can install everything, but you will encounter longer installation times and possible installation errors at the end of the process.
- ¿What if I want to install MongoDB in another folder?
o You can install it in another folder, but it is not guaranteed that you will have a complete successful installation, I recommend installing it in suggested folder.
- ¿Version of MongoDB affect this tutorial?
o Basically, not unless your version of MongoDB doesn’t include Mongo Compass
- ¿I have another type if problem, what can I do?
o MongoDB encounters other problems related to installation, most of them are about firewall restrictions and general access permissions in computer user.