How to Install MongoDB in Catalina OS

28 January, 2020

With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the "root" directory ( / ) from the command line, such as with Terminal. Read more...

1. Download the files from MongoDB's page:

MongoDB recommends to use the most complete version of MongoDB Server, in order to do this, we will download MongoDB Enterprise. Download the package for your SO in TGZ format.

2. Extract the files:

$ tar -xvzf [name-of-the-file.tgz]

3. Copy all the bin files to the root of your computer:

$ cd [name-of-the-folder]/bin
$ sudo bash
$ cp * /usr/local/bin
$ exit

4. Create the folder for the database:

$ sudo bash
$ mkdir -p ~/data/db
$ chmod 777 ~/data
$ chmod 777 ~/data/db
$ exit

6. Create a MongoDB configuration file:

$ touch /usr/local/etc/mongod.conf

6. Modify the DB path:

Write this on the same mongod.conf file

  dbPath: /Users/[youruser]/data/db

7. Create an alias to overwrite the standard DB path, and change the daemon

We need to modify our .zshrc file, adding:

alias mongod='mongod -f /usr/local/etc/mongod.conf'

And that's all

Happy Coding ❤️