Skip to content

Instantly share code, notes, and snippets.

@khanakia
Last active November 22, 2019 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khanakia/1d335f4ca2e843d14fab69e5e3fe18cd to your computer and use it in GitHub Desktop.
Save khanakia/1d335f4ca2e843d14fab69e5e3fe18cd to your computer and use it in GitHub Desktop.
Mongodb on Ubuntu 18

Installing MongoDB on Ubuntu 18 (AWS ARM64)

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

Note: I was getting this error "E: Unable to locate package mongodb-org" in order to resolve this issue i had to modify this line echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

Useful Terminal Commands

mongo --version service mongod start service mongod stop service mongod restart

Default Config file path

/etc/mongod.conf

#Enable Authentication https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac

I used this command to addUser with Root role

db.createUser(
  {
    user: "root",
    pwd: "password",
    roles:["root"],
    passwordDigestor: "server"
  }
)

Useful Commands

use admin // select Db

db.auth("root", "password")

db.dropUser('user') // Remove user

db.dropAllUsers({})

db.getUsers({}) // get all the users

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment