// config file
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
> default mongo location: /usr/local/var/mongodb
> config location: /usr/local/etc/mongod.conf
// Check the key paths of mongo by running `db.serverCmdLineOpts()`
> db.serverCmdLineOpts()
{
"argv" : [
"/usr/local/opt/mongodb-community/bin/mongod",
"--config",
"/usr/local/etc/mongod.conf"
],
"parsed" : {
"config" : "/usr/local/etc/mongod.conf",
"net" : {
"bindIp" : "127.0.0.1"
},
"storage" : {
"dbPath" : "/usr/local/var/mongodb"
},
"systemLog" : {
"destination" : "file",
"logAppend" : true,
"path" : "/usr/local/var/log/mongodb/mongo.log"
}
},
"ok" : 1
}
use admin
db.createUser(
{
user: 'admin',
pwd: 'password',
roles: [ { role: 'root', db: 'admin' } ]
}
);
exit;
// grant auth access
// https://stackoverflow.com/questions/23943651/mongodb-admin-user-not-authorized
mongo --port 27017 -u "admin" -p "password" --authenticationDatabase "admin"