Newbie - Mongod not working

I am very new to coding, terminal and using mongodb. I have been taking a udemy course and got past the mongodb installation and setup just fine and out of no where after I barely started the next project I started getting these errors when starting mongod. I spent a week trying to figure it out until I just tried to remove mongodb completely off my computer and reinstall everything. I am pretty sure I failed at that because it still does not work. I do not understand the error messages or which ones are even errors. The console logs are really daunting to look at for me because I am so new. I got stuck on this about 2 months ago and I had to stop for awhile and I started working on it a couple days ago and I just am completely stuck here. Some people suggested taking free courses which I think is a good idea once I can get this working again.
I have tried to switch the port #, I tried to change the dbpath location and it still does not load up. Can someone help me?

Thanks!

Error says non existent dirpath
What is your OS?
Did you try to create /data/db as suggested
How did you start mongod after changing the dirpath?

You can always start your own mongod by giving different values like port,dbpath other than default values

mongod --port --dbpath --logpath --fork
Choose a dir where your mongod can read/write say your home directory

Mac Big Sur.
I tried changing the port and dbpath many times.
mongod --dbpath data/db
mongod --port 27018

data/db is not same as /data/db
One is a relative path and other one is absolute path
First command failed because it could not find dbpath directory
Second command failed as you did not specify dbapth so it looks for default dir /data/db which is not existing as you created it under some other dir
Before you start mongod cd to the each dir you mentioned in your command or config file

1 Like

I have cd into data/db and the folder pops up. I changed the config file under /usr/local/etc/mongod.conf to data/db as well. I imagine what ever am stuck on is probably super simple. I am so new and I spent weeks trying to figure this out but I am completely stuck. I really appreciate your help.

I repeat data/db is not same as /data/db
show me the output of cd /data/db
I need exact screenshot (not manually typed) of your terminal
In Mac Big Sur access to root folder is removed
So creating /data/db dir would have failed and you created it somewhere else
So give that absolute path.It will work

1 Like

if I cd /data/db
bash: cd: /data/db: No such file or directory

Yes i understood
Where did you create your data/db dir?
If you are confused with Unix dir structure give a simple dirpath

mongod --port 28000 --dbpath your_home_dir --logpath your_home_dir/mongod.log --fork
After mongod is up make sure to connect using your_port_number

mongo --port 28000

Hope it clarifies

1 Like

Hey @base_az,

Welcome to the MongoDB Community forum.!!

We hope that you were able to solve your Mongodb configuration issue.
We want to wish you all the best for your MongoDB learning Journey and all future endeavors.:sparkles:

In case of any help around MongoDB, please feel free to reach out to us. We and our super awesome community peers will be happy to help.!!

And, a big shout-out to @Ramachandra_Tummala for responding instantly and helping @base_az. :clap: We highly appreciate it.

Kind Regards,
Kushagra

I am sorry. I can’t emphasize enough how new I am. I am trying to google what you are saying because I don’t understand what the log path is or how to even search where it is. I vaguely know what forking is with git hub but I have no idea the context of how to use that now. I spent some time trying to figure out each of your messages before responding but I just don’t understand.

I just saved my data/db on the home directory (I think). So the if I open the folder it is my username folder. I have moved it around and used mongod --dbpath data/db to change the location.

Show the output of below commands

pwd
cd data/db
ls
All you have to do is give valid paths for dbpath and logpath parameters in your command

How did you start mongod in your first post?(i think it was just mongod)
You mentioned you changed dir from /data/db to something else
After changing this how did you try to start mongod again
mongod can be started in different ways with and without config file or from command line
So show us clearly what you attempted

pwd
/Users/myName
cd/ data/db
ls

I use mongod to boot it. and mongod --dbpath to change but I would use mongod after that. I am sorry, I am sure this is as frustrating for you as it is for me. I really do appreciate all your help. I am going to take some more entry level terminal and mongod classes once I can get it working again. Thank you.