MongoDB 를 사용하다 몇가지 사용 Tip 을 남깁니다.
아래 내용은 https://docs.mongodb.com/manual/reference/method/ 에서 참고했습니다.
MongoDB ConnectionString
mongodb://[UserID]:[PW]@[IP]:[port]
mongodb://jumptovbuser01:woojjano1!@10.100.28.102:27107
MongoDB Shell Access
mongo --host 0.0.0.0 --port 27107 -u "jumptovbuser01" -p "woojjano1!" --authenticationDatabase "admin"
MongoDB Account.
Add Account
use admin
db.createUser({user : "jumptovbuser01" , pwd : "woojjano1!", roles : [{ role : "userAdminAnyDatabase" , db : "admin" }, { role : "readWrite" , db : "ccms" }]})
db.createUser({user : "jumptovbuser02", pwd : "woojjano2@", roles : [{ role : "readWrite" , db : "woojjaDB" }]})
Add Role
db.grantRolesToUser("jumptovbuser01", [{ role : "userAdminAnyDatabase" , db : "admin" }])
db.grantRolesToUser("jumptovbuser02" , [{ role : "readWirte" , db : "woojjaDB" }] )
Change Password
db.changeUserPassword("jumptovbuser01" , "woojjano3#")
Delete Account
db.dropUser("jumptovbuser02")
Add MongDB Database.
use woojjaDB
switched to db woojjaDB
db.dropDatabase()
MongoDB Database Method
db.createCollection()
db.cloneDatabase()
db.createView()
db.dropDatabase()
db.cloneCollection()
MongoDB CRUD
db.myCollection.find()
db.myCollection.insertOne({item: "card", qty: 15 })
db.myCollection.insertMany()
db.myCollection.updateOne()
db.myCollection.updateMany()
db.myCollection.replaceOne()
db.myCollection.save()
db.myCollection.deleteOne()
db.myCollection.deleteMany()
db.myCollection.drop()
db.myCollection.createIndex()
MongoDB commands
help
db.help()
show users
show dbs
show collections
show roles
show profile
...
행복한 고수되셔요.
woojja ))*
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\