-
Make sure
noauth = trueis 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 = trueand commentnoauth = trueat/etc/mongodb.conf
# 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, ... })