Skip to content

Instantly share code, notes, and snippets.

@JAlbertoGonzalez
Created April 1, 2019 19:54
Show Gist options
  • Select an option

  • Save JAlbertoGonzalez/58b409737379cd15f80fb27421fa045f to your computer and use it in GitHub Desktop.

Select an option

Save JAlbertoGonzalez/58b409737379cd15f80fb27421fa045f to your computer and use it in GitHub Desktop.
MongoDB installation & configuration on Ubuntu
1. Install MongoDB
sudo apt-get install mongodb
2. Edit configuration file to allow any access w/out user/password authentication
sudo nano /etc/mongodb.conf
Search line:
# noauth = true
Uncomment the file removing "#"
If the line doesn't exists, write down yourself.
3. Start/Restart mongodb service
sudo service mongodb start
sudo service mongodb restart
4. Login into mongodb
> mongo
5. Use the database name you will
> use MyAwesomeDatabase;
6. Create user credentials
> db.createUser({
user: "userName",
pwd: "PaSSWoRD",
roles: [{
role: "userAdminAnyDatabase",
db: "admin"
}]
});
7. Logout from database
> exit;
8. Edit /etc/mongodb.config and restore # noauth = true
9. Restart the service
> sudo service mongodb restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment