Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is mongo shell installed on Amazon Linux?

I successfully installed MongoDB on an Amazon Linux AMI by following this tutorial: https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-amazon/

The log (/var/log/mongodb/mongod.log) shows that mongo is up-and-running, so I know it was correctly installed.

However, I can't figure out how to access the mongo shell. I know the shell package was installed because:

$ sudo yum install mongodb-org-shell
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest                                         | 2.1 kB     00:00
amzn-updates/latest                                      | 2.3 kB     00:00
Package mongodb-org-shell-3.0.12-1.amzn1.x86_64 already installed and latest version
Nothing to do

Where can I find/how do I run the Mongo shell on my EC2 instance?

like image 449
T. Ato Avatar asked Sep 01 '25 20:09

T. Ato


1 Answers

Go to your "mongodb installation dir" (Common Path is /etc/mongo):

cd <mongodb installation dir>

Type ./bin/mongo to start mongo:

./bin/mongo

If you have added the /bin to the PATH environment variable, you can just type mongo instead of ./bin/mongo.

To display the database you are using, type db:

db

The operation should return test, which is the default database. To switch databases, issue the use helper, as in the following example:

use <database>
like image 95
error2007s Avatar answered Sep 03 '25 13:09

error2007s