Skip to content

Instantly share code, notes, and snippets.

@intruxxer
Created November 21, 2013 17:20
Show Gist options
  • Save intruxxer/7585820 to your computer and use it in GitHub Desktop.
Save intruxxer/7585820 to your computer and use it in GitHub Desktop.
1) In mongo command line: (let say, set administrator)
> use admin;
> db.addUser('admin','123456');
2) Shutdown Server and exit
> db.shutdownServer();
> exit
3) Restart Mongod with --auth
$ sudo ./mongodb/bin/mongod --auth --dbpath /mnt/db/
4) Run mongo again in 2 ways:
i) run mongo first then login.
$ ./mongodb/bin/mongo localhost:27107
> use admin
> db.auth('admin','123456');
ii) run & login to mongo in command line.
$ ./mongodb/bin/mongo localhost:27107/admin -u admin-p 123456
* The username & password will work the same for mongodump and mongoexport.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment