Skip to content

Instantly share code, notes, and snippets.

@mariohmol
Last active November 29, 2016 17:23
Show Gist options
  • Save mariohmol/246eb67452e49fbebc35fd4b93098365 to your computer and use it in GitHub Desktop.
Save mariohmol/246eb67452e49fbebc35fd4b93098365 to your computer and use it in GitHub Desktop.
How to use local mongo

Create a folder to store the database, so in you console run:

Mac and Linux users:

  • sudo mkdir /data
  • sudo mkdir /data/db

Then change the owner using your user, changin the username for your username

  • sudo chown username /data/db

Windows:

  • md \data\db

Then you can run in your terminal mongod, check after if you have something like mongo is listening to port 27017

Now connect to mongodb using your root user:

sudo mongo

Inside the console that just opened, type this

use admin
db.createUser(
  {
    user: "siteUserAdmin",
    pwd: "password",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

Now you have a username siteUserAdmin with password password that can do anything in mongo database.

Open your MongoHub, click on the add icon, give a name localhost, put the username siteUserAdmin and password password. When you save will show a localhost icon, double click, then in the new screen click on add , so you can create a new database.

After you create, right click in the database name and choose New Collection, give a name for that as well. Now if you right click the collection name, you can add/remove/update new items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment