Sajith dilshan
Sajith dilshan

Reputation: 161

Can't run "mongo" command (mongo shell) on Ubuntu after installation

I am new to MongoDB. I already read the docs and MongoDB Community Edition. It is working

enter image description here

but, I tried to run the "mongo" command: It is not working!!

enter image description here

...So i did:

sudo apt install mongodb-clients

(I saw after that this command uninstalled the mongodb server, which i had to install again)

When it finished, i tried again the "mongo" command. It is not working !! How do I solve this?

Upvotes: 9

Views: 19693

Answers (3)

rait
rait

Reputation: 1

you may want to try "mongosh" command

Upvotes: -1

GeertPt
GeertPt

Reputation: 17846

The mongodb-server and the mongodb-clients debian packages were for MongoDB 3.x, maintained by Ubuntu.

Since MongoDB 4.x, MongoDB provide their own debian packages, but they named them mongodb-org-server, mongodb-mongosh and mongodb-cli. The client command mongo is split into two different commands mongocli and mongosh.

Upvotes: 12

Volkorp
Volkorp

Reputation: 316

You may want to try "mongosh" command.

As specified on documentation you provided.

Start a mongosh session on the same host machine as the mongod. You can run mongosh without any command-line options to connect to a mongod that is running on your localhost with default port 27017.

You need a client in order to interact with mongoDB deployment such as mongosh or Compass.

The MongoDB Shell, mongosh, is a fully functional JavaScript and Node.js 16.x REPL environment for interacting with MongoDB deployments. You can use the MongoDB Shell to test queries and operations directly with your database.

Hope It helps.

Upvotes: 19

Related Questions