A practical guide to MongoDB and How to Install It on Catalina OS
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.
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:
For relational databases, we use SQL (Structured Query Language), which is a query language used to get the information we need from the database. It is a simple language to learn and feels similar to programming, however it is not programming. For non-relational databases, we use the most popular programming language today, JavaScript, and the data is structured in JSON (JavaScript Object Notation), which is not a query language but a way of structuring the data so that any program can understand it.
Examples:
Bases de datos | |
Relationals (SQL) | Non-relationals (NoSQL) |
MySQL PostgreSQL Oracle | MongoDB Redis CouchDB |
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.
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.
Here are a couple of reasons why you should be using MongoDB in your projects.
If you use NodeJS as your backend, you are most likely using a MEAN (Mongo Express Angular Node.js) or MERN (Mongo Express React Node.js) architecture. And if you're not using JavaScript for your projects, don't worry! With the right drivers, you can use MongoDB for virtually any programming language.
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.
This is probably the biggest advantage of MongoDB, since you don't have to pay for licenses to use it within your project.
Prerequisites:
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.
.
$tar -xvzf [name-of-the-file.tgz]
$ cd [name-of-the-folder]/bin
$ sudo bash
$ cp * /usr/local/bin
$ exit
$ sudo bash
$ mkdir -p ~/data/db
$ chmod 777 ~/data
$ chmod 777 ~/data/db
$ exit
$ touch /usr/local/etc/mongod.conf
Write the following into the file you just created:
storage: dbPath: /Users/[youruser]/data/db
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! ❤️
Follow the steps of more than a thousand career changers and entrepreneurs that launched their careers in the tech industry with Ironhack's bootcamps.