1.進(jìn)入mongodb命令行管理
C:\Documents and Settings\Administrator>mongo
MongoDB shell version: 1.8.1
connecting to: test
?
2.顯示數(shù)據(jù)庫(kù)
> show dbs
admin?? (empty)
local?? (empty)
test_db 0.03125GB
?
3.使用數(shù)據(jù)庫(kù)
> use test_db
switched to db test_db
?
4.添加數(shù)據(jù)庫(kù)用戶
> db.users.save({username:"gerald"})
?
5.查找數(shù)據(jù)庫(kù)用戶
> db.users.find()
{ "_id" : ObjectId("4ddf396e641b4986d346fe89"), "username" : "gerald" }
?
6.添加隸屬于某個(gè)數(shù)據(jù)庫(kù)的用戶
> use test_db
switched to db test_db
> db.addUser("gerald","123456")
{
??????? "user" : "gerald",
??????? "readOnly" : false,
??????? "pwd" : "f528f606b8635241c7f060408973b5b9"
}
?
7.以用戶驗(yàn)證的身份登錄數(shù)據(jù)庫(kù)
> use test_db
switched to db test_db
> db.auth("gerald","123456")
1
PS: 1代表驗(yàn)證成功, 0代表驗(yàn)證失敗
?
關(guān)鍵詞:數(shù)據(jù)庫(kù)? NoSQL? MongoDB? Database
?