'mongodb-community not working on Apple M1
I've installed mongodb-community version 5.0 using brew, following this post's answer for M1 Apple Silicon Macs: How to install Mongodb on Apple M1 chip
Everything works fine, until the 6th step.
After running "mongo" in my terminal, I get the following errors.
I searched over stackoverflow and suspected that perhaps the mongodb service is not running, but the command "brew services list" gives the following output.
Running "mongod" gives the following error.
Yet, checking "mongo --version" gives a clear indication of installation.
I have also uninstalled mongodb various times, started afresh with the whole procedure.
I'm so frustrated at this point. It would be really helpful if someone could let me know what's wrong in this process/how I could fix it.
PS: This is one of my first posts and I'm sorry if it is not structured well or does not follow a community guideline. I can try to edit the post if any rule is violated.
Thank you.
Solution 1:[1]
This solution worked for me Read-only file system when attempting mkdir /data/db on Mac rom the official docs https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
Install homebrew and run the following commands
sudo chown -R $(whoami) $(brew --prefix)/*
then
brew tap mongodb/brew
then
brew install [email protected]
and
brew services start mongodb-community
or
mongod --config /usr/local/etc/mongod.conf
then
ps aux | grep -v grep | grep mongod
and
mongo
to verify you can run show dbs in the mongo shell
Solution 2:[2]
Please follow this step for reinstalling mongodb, it works for me:
- 1st: run this command (Prerequisites)
xcode-select --install
\\note: Homebrew requires the Xcode commandline tools
- 2nd: install Homebrew for M1 chip (Prerequisites)
- 3rd: run this command to get Homebrew formula that work with mongodb
brew tap mongodb/brew
- 4th: run this command to get mongodb version 5
brew install [email protected]
- 5th: run this command to run mongodb in the background
brew services start [email protected]
// I notice that if I don't run this command I cannot connect to the server and receive the same error message like you
- 6th: just run mongo and enjoy. I hope it works.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Faisal Nazik |
| Solution 2 | Heang Sok |
