MongoDB 5.0 starts only as root

I’m using Mac M1 and I followed the steps in the documentation to install MongoDB 5.0 but the step to start the service doesn’t work. Weirdly the log file also isn’t updated. But when I run the same command with sudo then the service starts and the log also gets updated. This issue wasn’t there in MongoDB 4.2.

Is there a way I can start MongoDB 5.0 without sudo?

:wave:

Hi @Niraj_Nandish, and welcome to the MongoDB Community forums.

  • How did you install MongoDB on your Mac? Via brew or manually installing it?
  • Are you seeing any errors written to the terminal window?
  • How are you trying to start the mongod process?
  • Can you run mongod --dbpath <database file path> --logpath <database log path> from the command line without issue, or do you get an error?

I have an Intel based Mac and I run without sudo. I’m assuming that your user doesn’t have permissions to write to the log, and possibly the data, files and that’s causing the issues.

2 Likes

How did you install MongoDB on your Mac? Via brew or manually installing it?

I installed it using brew

Are you seeing any errors written to the terminal window?

The first time I run the command to start the brew service, it returns Successfully started mongodb-community@5.0 (label: homebrew.mxcl.mongodb-community@5.0) even though it has failed to start. On the second run it gives the following error

Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/niraj/Library/LaunchAgents/homebrew.mxcl.mongodb-community@5.0.plist` exited with 5.

How are you trying to start the mongod process?

I’m starting the process with the following command

brew services start mongodb/brew/mongodb-community@5.0

Can you run mongod --dbpath <database file path> --logpath <database log path> from the command line without issue, or do you get an error?

I get the following output, not sure if it’s an error or not

{"t":{"$date":"2022-08-07T04:49:37.098Z"},"s":"I",  "c":"CONTROL",  "id":20697,   "ctx":"-","msg":"Renamed existing log file","attr":{"oldLogPath":"/opt/homebrew/var/log/mongodb/mongo.log","newLogPath":"/opt/homebrew/var/log/mongodb/mongo.log.2022-08-07T04-49-37"}}

I’m assuming that your user doesn’t have permissions to write to the log, and possibly the data, files and that’s causing the issues

MongoDB was working fine before with 4.2 and yesterday when I upgrade it to 5.0 it stopped working my user. If I downgrade back to 4.2 then it’s working fine.

So somehow the permission of some data file and the mongo.log file had been changed to root user. Changing them back fixed my issue. Weird that it broke for 5.0 and not for 4.2.

Thanks for the help @Doug_Duncan

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.