Published on

Setup MongoDB Client on CentOS 6

Authors

I have a bastion host that is still running CentOS6 and epel repos provides mongodb-shell version 2.x and Mlab requires version 3.x

Setup the Repositories

Create the repository:

/etc/yum.repos.d/mongodb.repo
$ cat > /etc/yum.repos.d/mongodb.repo << EOF
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
EOF

Update the repository index:

$ sudo yum update -y

Install MongoDB-Shell

Install the MongoDB Shell Client:

$ sudo yum install mongodb-shell -y

Update: Thanks to Rick, when you use CentOS 7, you can install the Shell Client as instructed below:

$ sudo yum install mongodb-org-shell -y

Connect to your Remote MongoDB Instance:

$ mongo remotedb.mlab.com:27017/<dbname> -u <user> -p <pass>