Mongo command not found


mongo comman not found

Hi @Prajwal_Janbandhu and welcome to the MongoDB community.

This portion of your screenshot looks to provide some answers:

Did you update your $PATH variable as recommended? If you did, do you see the path mentioned?

MongoDB 6.0 was recently released. Is there a reason you’re using MongoDB 4.4? While 4.4 will be supported for about 6 more months, would it make sense for you to upgrade to a newer version of the database to get the most recent security updates and features?

1 Like


i had installed version 5.0 and also i want to run the mongod but it’s showing this error i had included the path also.

sudo export PATH=$PATH:/usr/local/Cellar/mongodb-community@5.0/5.0.10/bin
this path i have uploaded in bash profile and i have tried to open the executable file from that path but the same error occurs. please help regards with this.

You might have installed mongod as service
When you issued mongo looks like it did connect to default mongod running on port 27017
Just connect and issue db,show dbs
You don’t have to start mongod again
That may be the reason it is not allowing mongod to come up as you already have a mongod up and running

The error in your log file states that the mongod process cannot unlink the file /tmp/mongodb-27017.lock because permission is denied. My guess here is that the file is owned by the root user. You can check that by running ls -alh /tmp/mongodb-27017.lock.

To correct this issue, you can delete the file sudo rm /tmp/mongodb-27017.lock and then start the mongod process once more, which will recreate the file.

After running this command
sudo rm /tmp/mongodb-27017.lock
It says rm: /tmp/mongodb-27017.lock: No such file or directory.

Half way down the screenshot you will see the following line:

This states that the MongoDB engine cannot find the path /data/db. This is the default location to use for the data files if an alternate path is not provided on the command line or a config file. Since the path doesn’t exist, the process cannot create the database files that are needed and the process then shuts down.

If you installed MongoDB with brew, you should have a config file at /usr/local/etc/mongodb.conf that overrides the default location and writes the database files to /usr/local/var/mongodb. If this is the case, try running mongod -f /usr/local/etc/mongodb.conf

1 Like

it says that no such file or directory after running
mongod -f /usr/local/etc/mongodb.conf
this command

Hi @Prajwal_Janbandhu can you explain how you installed MongoDB on your MacBook? I assumed you used brew but maybe you just downloaded the archive. If you just downloaded the archive, then obviously none of the configuration files or paths will be set up as that’s something that brew does for you.

I had installed mongodb using brew only and followed the instructions given on the official page of mongodb

If you run brew services it should show the path to the plist file that brew uses to run the service. For my machine this points to ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist. This file will contain, among other things, the program arguments which controls how brew would start things up:

image

I see that I made a typo and the config file is mongod.conf and not mongodb.conf. Sorry about that.