In my case: sudo chown -Rv jadekim /Users/jadekim/data/dbįinally, you can run mongod successfully! Once the install is finished it will add two lines at the bottom of your php.ini file. Follow the inline instructions as they appear. sudo pecl install mongodb You may need to follow some additional configuration. To install the mongodb extension you need to use pecl. We need to set permissions for the data and log directories: sudo chown -Rv YOUR_USER_NAME /Users/YOUR_USER_NAME/data/db The mongodb install has been removed from Homebrew. Mongod -dbpath=/Users/jadekim/data/db -logpath=/Users/jadekim/data/log/db/mongo.logĮxception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /Users/jadekim/data/db, terminating Then run mongod manually by setting up the db and log path with following command. Tip: Find out your username by running this command: whoamiĪnd create the log directory: sudo mkdir -p /Users/jadekim/data/log/db Since you cannot create directories in root system, create the db directory with sudo mkdir -p /Users/YOUR_USER_NAME/data/db. On macOS 10.15 Catalina, you must use a different data directory, such as /usr/local/var/mongodb. Starting with macOS 10.15 Catalina, Apple restricts access to the MongoDB default data directory of /data/db. That might be because you are using macOS Catalina. If you get the exception similar to below, you will need to create a directory for mongo data with following command: sudo mkdir -p /data/dbĮxception in initAndListen: NonExistentPath: Data directory /data/db not found., terminatingīUT you might get the another error, mkdir: /data/db: Read-only file system. Set mongo db and log path manually - Troubleshooting errors for beginners and macOS Catalina To connect and use MongoDB, open a new Terminal and run mongo. To verify that MongoDB has started successfully: ps aux | grep -v grep | grep mongod It uses the default conf file and paths for mongodb and the log. To stop the server, brew services stop mongodb-community. To run mongod as a service, brew services start mongodb-community. the data directory path: /usr/local/var/mongodb.the log directory path: /usr/local/var/log/mongodb.the configuration file: /usr/local/etc/nf.Homebrew will create the conf file and paths below as defaults. Setup a custom Homebrew tap and install mongoĪnd install mongo: brew install mongodb-community (optional) Install node js with brew by the line below if you need: brew install node 2. Go to and find a command for installing Homebrew and run in your Terminal prompt. Homebrew is a Package Manager for macOS/Linux.