Skip to content

Instantly share code, notes, and snippets.

@alesegdia
Last active September 24, 2017 22:11
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 alesegdia/d6be10cb7578af758532 to your computer and use it in GitHub Desktop.
Save alesegdia/d6be10cb7578af758532 to your computer and use it in GitHub Desktop.
MongoDB startup

MONGODB STARTUP

  • Install MongoDB

  • Make sure noauth = true is uncommented at /etc/mongodb.conf (enabled by default, but just in case)

  • Create admin user:

use admin
db.createUser(
  {
    user: "siteUserAdmin",
    pwd: "password",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)
  • Optionally (must in production), set auth = true and comment noauth = true at /etc/mongodb.conf

Quickstart

# Login into database
mongo whatever.domain.com:12345/mydatabase -u user -p pass

# Create new collection
db.createCollection("collectionName")

# Insert element in collection
db.myCollection.insert({ "_id": 0, ... })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment