Skip to content

Instantly share code, notes, and snippets.

@brunoqs
Last active April 24, 2020 21:17
Show Gist options
  • Save brunoqs/98a316919dffa4ff2c91da9ef02b9dab to your computer and use it in GitHub Desktop.
Save brunoqs/98a316919dffa4ff2c91da9ef02b9dab to your computer and use it in GitHub Desktop.
Mongodb Backup Restore
mongodump -h ip:port -d db -u user -p pass -o .
mongorestore -h ip -d db -u user -p pass jifcast/
query to csv:
mongoexport -h localhost -d jifcast -u jifcast -p jifcast -c episodes --type=csv --fields
name,_id,channel,downloadCount,likeCount,listenCount -q '{"likeCount": {"$exists": true }}' --out count.csv
create root user:
db.createUser(
{
user: "mongo-root",
pwd: "passw0rd",
roles: [ { role: "root", db: "admin" } ]
}
)
create admin user:
> use admin
db.createUser(
{
user: "mongo-admin",
pwd: "passw0rd",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
create normal user:
> use my-database
db.createUser(
{
user: "my-user",
pwd: "passw0rd",
roles: [ { role: "readWrite", db: "my-database" } ]
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment