- access to mongo
mongo
- create database
user database_name
- create user
db.createUser({
user: 'your_user_name',
pwd: 'secretPassword',
roles: [{ role: 'readWrite', db:'database_name'}]
})
sudo nano /etc/mongod.conf
- then edit net:
# network interfaces
net:
port: 27017 <- you can change port
bindIp: 0.0.0.0 <- change from 127.0.0.1 to 0.0.0.0 for remote access
- then find security
security:
authorization: 'enabled'
- Save
sudo service mongod restart
- you can watch log to confirm mongo service restart successfully
sudo tail -f /var/log/mongodb/mongod.log
- terminal
mongo -u your_user_name -p secretPassword 123.45.67.89/database_name
replace your_user_name and secretPassword and database_name youself