Created
November 21, 2013 17:20
-
-
Save intruxxer/7585820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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