this is the main error:
Exception in initandlisten: nonexistentpath: data directory /data/DB
not found
Catalina, the latest version of the MAC system, has made a surprising change: it does not allow changes to the root directory (which is also discussed in the forum topic)
% sudo mkdir -p /data/db
mkdir: /data/db: Read-only file system
Unfortunately, this is not explicitly stated in Apple’s Catalina release notes, except for the brief mention in Catalina features:
MacOS Catalina runs on a dedicated read-only system volume
Since the directory /data/DB
is encoded as mongodb default directory, one solution is to specify a directory where dbpath is not on the root directory. For example:
mongod --dbpath ~/data/db
This will put the mongodb data in your home directory. Just make sure that the path ~/data/DB does exist
alternative method
An alternative method is to use the instructions in installing mongodb Community Edition on MacOS brew
:
brew tap mongodb/brew
brew install mongodb-community
By default, this creates some other files:
Configuration file (/ usr/local/etc/mongod. CONF)
Log directory path (/ usr/local/var/log/mongodb)
To run the data directory path (/ usr/local/var/mongodb), mongod
you can:
Run the command manually from the command line (you can use an alias for convenience):
mongod --config /usr/local/etc/mongod.conf
Use to run brew services with mongodb as a service. Note that this will run mongodb as a stand-alone node (rather than a replica set), so functionality depending on oplog (such as changestream) will not work unless you modify the mongod configuration file:
brew services start mongodb-community
Similar Posts:
- [Solved] Brew Install MongoDB Error: “Error: No available formula with the name “mongodb””
- Unable to start mongod after installing mongodb in Ubuntu
- Raspberry pie: How to Solve Mongodb installation error
- Error reported when Java connects mongodb com.mongodb.mongosocketopenexception: exception opening socket has been solved
- [Solved] MongoDB Start ERROR: child process failed, exited with error number
- MongoDB Startup Error: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
- MongoDB:Unclean shutdown detected
- Mongovue is unable to create collections and log in with user name and password
- [Solved] Mongodb Error: NETWORK [thread1] Failed to connect to 127.0.0.1:27017
- [Solved] Mongodb startup error: about to fork child process, waiting until server is ready for connections.