Cant run "mongo" command (mongo shell) on Ubuntu after installation

6,644 views
Skip to first unread message

Julio Wandekoken

unread,
Oct 7, 2019, 7:23:30 PM10/7/19
to mongodb-user
Hi guys. I am new to MongoDB. I already read the docs and just cant make it work. 

I installed the MongoDB using the ".deb" file, and i also tried follow up the docs:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

The thing is: i just cant run or find the "mongo" file. 

I am using Ubuntu 18.04. 

Then i did on my terminal, after the installation:

"mongod --version"


And the response was:


 
db version v4.2.0
git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1804
distarch: x86_64
target_arch: x86_64
 

Then i tried to run the "mongo" command:

 
Command 'mongo' not found, but can be installed with:
sudo apt install mongodb-clients

...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. Response:


MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2019-10-07T10:09:59.055-0300 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2019-10-07T10:09:59.056-0300 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed

So i tried to start the mongoDB first with "sudo service mongod start". Response:


Failed to start mongod.service: Unit mongod.service not found.


(the mongo client uninstalled the server. So i installed again the server using the ".deb" file)


I just dont know what to do. I already tried to follow the documentation at the ubuntu installation section (https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/) and also did not worked. I just dont know what to do. I already uninstalled it and installed a couple of times.

I am very frustrated. Someone know how to properly install it or faced similar issues?  


I tried the command "updatedb" and when completed, i tried:


which mongod


Response:

/usr/bin/mongod
 

The 'mongo' program was not supposed to be in the same dir that the "mongod"?


When i tried:


which mongo
 

I get nothing. 


Can someone please help me?

Jesse Sunkara

unread,
Oct 7, 2019, 8:38:33 PM10/7/19
to mongod...@googlegroups.com
Hi Julio,

I'm not an expert at installation on various flavors.  It seems to me that the client "mongo" wasn't installed during your last try.  The client "mongo" will be installed in the same directory as the server "mongod".   Seems like the install didn't go well the first time around.  Instead of trying to salvage, try to cleanup the failed install and start over again.  Use the instructions in your link.  For example:
ps -ef|grep mongod --> kill <pid>
To check if Ubuntu’s mongodb package is installed on the system, run sudo apt list --installed | grep mongodb. You can use sudo apt remove mongodb and sudo apt purge mongodb to remove and purge the mongodb package before attempting this procedure. 
Verify that the install is removed (/usr/bin/m*)  and then try a clean install as documented in your post:  sudo apt-get install -y mongodb-org
If the Debian service is not created, you should still be able to start it manually (create a new config file if necessary but you don't need it for default port and a localhost noauth connection).   
If you haven't already, make sure to sign-up with mongod university and take the delightful course "M103: Basic Cluster Administration".  Those concepts will serve you well (but not for the install).

I'm not sure why you are seeing an error relating to openSSL.  It may be because the config file is looking for a keyfile?  Not sure.  The default mongod.conf that the mongo server uses is installed as /etc/mongod.conf.  Check that for the keyfile and if no key exists, you can create the key.  For example: openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile.  I don't think you need to worry about this at the moment.  Start with a fresh install after remove/purge above.

I downloaded the enterprise edition and that went well on a different Linux flavor:  https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/

Hope this helps.  All the best.

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/dca376df-b739-44b6-b159-6b707c85e9e5%40googlegroups.com.


--

Pramod Jesse Sunkara
Mobile: 615-585-4747

 
Reply all
Reply to author
Forward
0 new messages