Specifying path of data directory

I am following this thread: macos - MongoDB can't find data directory after upgrading to Mac OS 10.15 (Catalina) - Stack Overflow).

When I enter mongod --dbpath ~/data/db Terminal stalls on this:

Hi @Ryan_Frost the mongod command you ran will start the server and then log all output to the current terminal, unless you state where to write the log data.

At the bottom of that log (third line from the bottom) it says that the server is listening on port 27017. Since you’re bound to localhost (that information is towards the middle of the log file) you should be able to start a new terminal window and run the mongo command to connect to the database and open a new MongoDB shell.

Are you having problems connecting to the MongoDB server? If so what errors are you getting?

I’ve usually ran mongodb by typing mongod. I get this when I type mongod

Sorry can only reply with one picture at a time:

Ok so in the first image you get an error stating that the address is already in use. This happens if you try to run two different mongod commands without changing the port. In this case the second server shuts down as expected.

For the second image I see a running mongo session and it’s ready for you to start working. There are warnings (you see these in the original message as well) that you should look into if this will be a production server.

The final image is a log file with the last few lines showing that you did indeed connect to the server from a mongo shell.

From what you’re showing everything is working as expected.

1 Like

Thanks @Doug_Duncan.
My metric for success used to be when I typed in mongod it would get everything running.
My Mac did an update to Catalina and it changed where the data/db directory was stored.

I’ve moved it to home. So my mongod --dbpath ~/data/db was trying to reset where mongodb reads it (what the stack overflow article suggested).