We all know how fun and efficient it can be to work on an Apple computer where you can prototype graphical interfaces, do data analysis, develop web applications, and even run database servers with your own equipment.
However, Apple can often surprise us with their OS updates that make programming a bit more challenging, such as the recent arrival of Catalina macOS. This update has changed how we work, since we can no longer write commands into our terminal that directly affect the root directory (/). That's why in this post we will teach you how to install MongoDB on Catalina macOS so that you can continue working efficiently with your Apple.
Relational vs Non-relational databases
Databases are the cornerstone of all technology platforms. Relational databases (SQL) are the ones we have always known and non-relational databases (NoSQL) are a relatively new development that took the world of technology by surprise and are here to stay. Some of the advantages of non-relational databases over relational ones are:
There's no redundancy.
They're much lighter.
They're much faster.
Bases de datos
What is MongoDB?
MongoDB is a database that belongs to a group of NoSQL, or non-relational, databases. In MongoDB, each record is stored in a JSON document which is composed of fields that are grouped in collections.
What do we use MongoDB for?
MongoDB can be used for any application or platform that needs to store semi-structured data. MongoDB is very useful when we are looking for scalability in our projects as it allows us to grow horizontally without problems.
Why use MongoDB?
Here are a couple of reasons why you should be using MongoDB in your projects.
If you expect your project to continuously evolve, MongoDB is the perfect database for you, as it will allow you to grow vertically as well as horizontally.
MongoDB allows us to create powerful queries with less code, saving a lot of time and making us more efficient when analyzing the metrics of our projects.
It's Open Source
This is probably the biggest advantage of MongoDB, since you don't have to pay for licenses to use it within your project.
How to install MongoDB on Catalina OS
Familiarity with the command terminal on your Mac
Download the MongoDB installation files:
MongoDB recommends that we use the more complete version of MongoDB Server, so we recommend downloading the MongoDB Enterprise version for macOS in TGZ format.
Extract the files:
$tar -xvzf [name-of-the-file.tgz]
Copy all files within the bin folder into the root:
$ cd [name-of-the-folder]/bin
$ sudo bash
$ cp * /usr/local/bin
Create the folder for the database:
$ sudo bash
$ mkdir -p ~/data/db
$ chmod 777 ~/data
$ chmod 777 ~/data/db
Create the configuration file for MongoDB:
$ touch /usr/local/etc/mongod.conf
Modify the database path:
Write the following into the file you just created:
storage: dbPath: /Users/[youruser]/data/db
Create an alias to overwrite the default MongoDB settings:
You will have to modify your .zshrc file by adding the following:
alias mongod='mongod -f /usr/local/etc/mongod.conf'
Done! Now you can run the mongod command on our terminal and use MongoDB normally.
Databases are a small but incredibly important part of the programming world. If you already know how to program or are just learning and want to take your skills to the next level, then you should look into our Web Development Bootcamp, where we will teach you how to use non-relational databases and many other tools that will make you into a full stack developer.
Happy Coding! ❤️