Last active
September 27, 2020 22:06
-
-
Save payamomrani/46eefc4641130e3b97e6696de334e846 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
mongod.exe --dbpath "D:\mongodb\data\db" | |
mongod --auth --port 27017 --dbpath /var/lib/mongodb | |
//User Login | |
mongo --port 27017 --authenticationDatabase "admin" -u "myUserAdmin" -p | |
//Backup Database | |
mongodump --db={db name} --out="{path}" --username={username} --password="{password}" | |
mongodump --db=omrani --out=D:/mongodb/data/backup/`date +"%m-%d-%y"` --username=omrani --password="{password}" | |
//Restore DB | |
mongorestore --db {dbName} --username {Username} --password {Password} --authenticationDatabase {dbName} --dir {Source Path} | |
db.createUser( | |
{ | |
user: "dbUseranem", | |
pwd: passwordPrompt(), // or cleartext password | |
roles: [ { role: "readWrite", db: "dbName" } ] | |
} | |
) | |
//Change Type Of Field | |
db.people.find().forEach( function(obj) { | |
if(obj.birth){ | |
obj.birth.birthday.year= new NumberInt(obj.birth.birthday.year); | |
obj.birth.birthday.month= new NumberInt(obj.birth.birthday.month); | |
obj.birth.birthday.day= new NumberInt(obj.birth.birthday.day); | |
db.people.save(obj); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment