1.進入mongodb命令行管理
C:\Documents and Settings\Administrator>mongo
MongoDB shell version: 1.8.1
connecting to: test
?
2.顯示數據庫
> show dbs
admin?? (empty)
local?? (empty)
test_db 0.03125GB
?
3.使用數據庫
> use test_db
switched to db test_db
?
4.添加數據庫用戶
> db.users.save({username:"gerald"})
?
5.查找數據庫用戶
> db.users.find()
{ "_id" : ObjectId("4ddf396e641b4986d346fe89"), "username" : "gerald" }
?
6.添加隸屬于某個數據庫的用戶
> use test_db
switched to db test_db
> db.addUser("gerald","123456")
{
??????? "user" : "gerald",
??????? "readOnly" : false,
??????? "pwd" : "f528f606b8635241c7f060408973b5b9"
}
?
7.以用戶驗證的身份登錄數據庫
> use test_db
switched to db test_db
> db.auth("gerald","123456")
1
PS: 1代表驗證成功, 0代表驗證失敗
?
關鍵詞:數據庫? NoSQL? MongoDB? Database
?
posted on 2011-05-27 15:38
jadmin 閱讀(107)
評論(0) 編輯 收藏