Created
October 22, 2014 18:10
-
-
Save d6u/aed1ac46cedfa48f8fd3 to your computer and use it in GitHub Desktop.
mongodb common notes
This file contains hidden or 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
| conn = new Mongo(); | |
| db = conn.getDB('admin'); | |
| db.createUser({ | |
| user: 'siteUserAdmin', | |
| pwd: 'password', | |
| roles: [{ | |
| role: 'userAdminAnyDatabase', | |
| db: 'admin' | |
| }] | |
| }); | |
| twitter = conn.getDB('twitter'); | |
| twitter.createUser({ | |
| user: '<%= env.MONGO_USER %>', | |
| pwd: '<%= env.MONGO_PASS %>', | |
| roles: [{ | |
| role: 'readWrite', | |
| db: '<%= env.MONGO_DB %>' | |
| }] | |
| }); |
This file contains hidden or 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
| mongod --port 27017 --smallfiles & | |
| MONGOD_PID=$! | |
| sleep 2 # Wait for mongod to bind port | |
| mongo /root/mongo-adduser.js | |
| sleep 2 # Wait for mongo to create admin user | |
| kill $MONGOD_PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment