0

I'm a new linux user, I am trying to setup mongodb on linux ubuntu 22.04 , I installed it using mongdoDB official documentation but it shows mongosh not working error mongosh command not found I have mongodb 6.0.5 version

I also had to uninstall and reinstall mongodb multiple times as it was showing

MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017] 

when i check the status by sudo systemctl status mongod command so I tried to find the solution, and I found this . I also used sudo rm /usr/bin/mongo* command as suggested by the user and I think this is where the problem begins. On runnig mongosh commmand it was showing

bash: /usr/bin/mongo: no such file or directory

after restarting my system now it is showing this

mongosh: command not found

I also tried installing mongosh from its official documentary it is still not working and showing the same error Do suggest some fixes

  • 1
    Does this answer your question? [mongo.exe not installed in Version 6.0.0](https://stackoverflow.com/questions/73081708/mongo-exe-not-installed-in-version-6-0-0) – Wernfried Domscheit Mar 22 '23 at 21:22
  • I already tried this and it says cannot install mongodb-server and mongodb-client , when I tried sudo upgrade only the above file it says files do not have installation instructions – Syed Yahya Ahmad Mar 23 '23 at 07:44
  • Did you pay attention to this note: "*The mongodb package provided by Ubuntu is not maintained by MongoDB Inc. and conflicts with the official mongodb-org package. If you have already installed the mongodb package on your Ubuntu system, you must first uninstall the mongodb package before proceeding with these instructions.*" – Wernfried Domscheit Mar 23 '23 at 09:42
  • Thanks @WernfriedDomscheit i actually ran ` sudo apt-get purge mongodb-org* ` this command many times when but now I ran ` sudo apt-get purge mongod-org* ` command thinking there might be some files with just mongod name and for some fortunate reason it is working perfectly fine now. – Syed Yahya Ahmad Mar 23 '23 at 17:38

1 Answers1

0

I came accross the same issue.

From what I understood this is happening because in the MongoDB version 6.0 the shell does not come preinstalled, you need to install it separately here.
mongo.exe became mongosh.exe
You can add the alias mongosh="/c/Program\ Files/MongoDB/Server/6.0/bin/mongosh.exe" to your .bash_profile and just type mongosh in your terminal to execute the shell.