0

I wasn't able to start MongoDB on my new Mac properly..

I installed everything new but Compass doesn't find anything.

First I do

brew services start mongodb-community@5.0

It seems to work

==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu

But when I check with

brew services list

I get

Name              Status  User       Plist
mongodb-community error   <UserName> /usr/local/opt/mongodb-community/homebrew.mxcl.mongodb-community.plist

Has someone an idea?

I use macOS Big Sur 11.6, Intel i7

chesterly
  • 15
  • 6
  • Did you check the log file? – Wernfried Domscheit Oct 18 '21 at 16:08
  • Recent Mac upgrades will not allow user files at the root of the system filesystem. Some MongoDB deployments assume the data directory is `/data`. These systems will not start as they cannot write to the directory `/data`. If this is your condition, you must configure the path to a writeable path by the user starting the `mongod` process. As described by Wernfried, check the log files. For Homebrew, I believe the default logs are at `/usr/local/var/log/mongodb/`, and I believe the default configuration file is `/usr/local/etc/mongod.conf` – barrypicker Oct 18 '21 at 17:57
  • https://stackoverflow.com/questions/13827915/location-of-the-mongodb-database-on-mac/13828103 – barrypicker Oct 18 '21 at 18:01
  • thanks first @WernfriedDomscheit and @barrypicker so much! So plan is to change `/usr/local/var/log/mongodb/mongo.log` right? And reset the data directory from `/data` to `/Users//Documents/databases/mongodb` for example? I'm a bit confused by the `mongo.log` and didn't found the `/data` path. Am I doing something wrong? – chesterly Oct 19 '21 at 11:28
  • `systemLog:` ` destination: file` ` path: /usr/local/var/log/mongodb/mongo.log` ` logAppend: true` `storage:` ` dbPath: /usr/local/var/mongodb` `net:` ` bindIp: 127.0.0.1` – chesterly Oct 21 '21 at 14:26
  • I changed now the `mongod.conf` with `storage: dbPath: /Users//data` .. but still same errors :/ @WernfriedDomscheit and @barrypicker any more hints? – chesterly Oct 21 '21 at 14:46
  • What do you see in `/usr/local/var/log/mongodb/mongo.log`? Please edit your question and put additional information there instead of a comment. – Wernfried Domscheit Oct 21 '21 at 14:50
  • @WernfriedDomscheit when I do `open /usr/local/var/log/mongodb/mongo.log` in the terminal I get an error message even if I open the terminal as an admin.. error message is `The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10826 "kLSNoLaunchPermissionErr: User doesn't have permission to launch the app (managed networks)" UserInfo=...` – chesterly Oct 21 '21 at 14:55
  • full error message here: https://stackoverflow.com/questions/69664429/error-when-trying-to-checkmongodb-log-file – chesterly Oct 21 '21 at 15:07

1 Answers1

0

Ok so I was trying so many things now, but in the end the solution was quite simple:

Just to be sure update Homebrew

brew update

Install / reinstall / update MongoDB if needed

brew install mongodb

After downloading Mongo, create the “db” directory

mkdir -p /data/db

Make sure you have the right permissions by running

> sudo chown -R `id -un` /data/db

And here we go!

As written here: Read-only file system when attempting mkdir /data/db on Mac

Mac does not allow to write the root folder. So MongoDB is not able to use that folder properly.

You can change to a writable directory with:

mongod --dbpath=/Users/user/data/db

Fixed!

chesterly
  • 15
  • 6