Last active
April 24, 2020 21:17
-
-
Save brunoqs/98a316919dffa4ff2c91da9ef02b9dab to your computer and use it in GitHub Desktop.
Mongodb Backup Restore
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
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