關(guān)于mongoDB的安裝與配置,mongo官網(wǎng)上已經(jīng)有很詳細(xì)的介紹了,這里僅列一下自己配置mongoDB的一些腳本,僅供參考
--進(jìn)入bin目錄
mongod -dbpath "d:\mongodb"
--安裝window服務(wù)
用—dbpath參數(shù)指出了數(shù)據(jù)庫的目錄,--logpath則指出了日志存放的目錄,而—serviceName參數(shù)則指出了命令安裝的服務(wù)名為MongoDB
-
mongod --logpath d:\mongodb\log --logappend --dbpath d:\mongodb --directoryperdb --install
--刪除服務(wù)
mongod -remove -serviceName "MongoDB"
--數(shù)據(jù)庫操作腳本,來自官網(wǎng)
C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongo
> // the mongo shell is a javascript shell connected to the db
> // by default it connects to database 'test' at localhost
> 3+3
6
> db
test
> // the first write will create the db:
> db.foo.insert( { a : 1 } )
> db.foo.find()
{ _id : ..., a : 1 }
> show dbs
...
> show collections
...
> help
--創(chuàng)建數(shù)據(jù)庫 user newDatabaseName
> use xiaodb
switched to db mkyongdb
> show dbs
admin 0.03125GB
local (empty)
--定義collection,然后插入數(shù)據(jù)
db.users.save( {username:"xiao"} )
--查找插入數(shù)據(jù)
db.users.find()
--修復(fù)命令
mongod –repair 本文出自:億恩科技【xuefeilisp.com】
服務(wù)器租用/服務(wù)器托管中國五強(qiáng)!虛擬主機(jī)域名注冊頂級提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|