Skip to content

Instantly share code, notes, and snippets.

@alexpaul
Last active November 27, 2021 02:02
Show Gist options
  • Save alexpaul/d78f918c5287704abd963ec722196284 to your computer and use it in GitHub Desktop.
Save alexpaul/d78f918c5287704abd963ec722196284 to your computer and use it in GitHub Desktop.
Key Locations of MongoDB paths on mac.
// 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment