Reputation: 43
I have successfully installed mongodb into my linux machine.
Please suggest how to access it remotely.
Upvotes: 0
Views: 14569
Reputation: 43
I worked on it and searched for it. Finally came up with following solution.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
service mongod status
use admin
db.createUser({user:"<username>", pwd:"<password>", roles:[{role:"root", db:"admin"}]})
mongo -u <username> -p <password> --authenticationDatabase admin
# Comment bindIp with #
service mongod restart
ufw allow 27017
ufw status
security:
authorization: enabled
mongo -u <username> -p <password> <ip-address>:27017/<collection-name>
Upvotes: 2