在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ 數(shù)據(jù)庫/ MongoDB安裝配置(Windows)
MongoDB教程
MongoDB覆蓋查詢
MongoDB數(shù)據(jù)建模
MongoDB聚合
MongoDB更改用戶密碼和自定義數(shù)據(jù)
MongoDB用戶
MongoDB分片
MongoDB創(chuàng)建集合
MongoDB文本搜索
MongoDB數(shù)據(jù)類型
MongoDB GridFS
MongoDB索引限制
MongoDB插入文檔
MongoDB刪除集合
MongoDB數(shù)據(jù)庫引用
MongoDB復制
MongoDB Map Reduce
Python連接MongoDB操作
MongoDB原子操作
MongoDB特點
MongoDB安全檢查表
MongoDB排序記錄
MongoDB自動遞增序列
MongoDB安裝配置(Windows)
MongoDB備份與恢復
MongoDB安裝配置(Ubuntu)
Ruby連接MongoDB操作
MongoDB部署
MongoDB索引
MongoDB分析查詢
MongoDB投影(選擇字段)
MongoDB刪除數(shù)據(jù)庫
MongoDB認證
MongoDB限制記錄數(shù)
MongoDB添加用戶
MongoDB固定循環(huán)集合
MongoDB高級索引
MongoDB數(shù)據(jù)庫的優(yōu)點
MongoDB快速入門
MongoDB創(chuàng)建數(shù)據(jù)庫
MongoDB啟用身份驗證
MongoDB歷史
MongoDB管理用戶和角色
MongoDB安裝配置(RedHat/CentOS)
MongoDB刪除文檔
Java連接MongoDB操作
MongoDB正則表達式
MongoDB查詢文檔
MongoDB關聯(lián)關系
PHP連接MongoDB操作
MongoDB更新文檔
MongoDB ObjectId

MongoDB安裝配置(Windows)

要在Windows上安裝 MongoDB,首先打開: http://www.mongodb.org/downloads 下載最新版本的MongoDB。確保根據(jù)您的Windows版本獲得正確版本的MongoDB。要獲取 Windows 版本,請打開命令提示符并執(zhí)行以下命令。

C:\Users\Administrator> wmic os get osarchitecture
OSArchitecture
64 位

如上所示,這里 Windows 版本是 64位的操作系統(tǒng),所以下載對應的 MongoDB-for-Windows 64位版本,如下圖所示 -

前提條件

MongoDB社區(qū)版需要Windows Server 2008 R2,Windows Vista或更高版本(注:本教程將演示在Windows10 46位系統(tǒng)上安裝MongoDB)。 .msi安裝程序包括所有其他軟件相關性,并將自動升級任何使用.msi文件安裝的舊版本的 MongoDB。

MongoDB安裝

在Windows資源管理器中,找到下載的MongoDB.msi文件,通常位于默認的“下載”文件夾中。 雙擊mongodb-win32-x86_64-2008plus-ssl-3.4.5-signed.msi文件。 將出現(xiàn)一組屏幕,指導您完成安裝過程。

下一步(Next>),在彈出的界面中,打上勾以表示“同意安裝協(xié)議” -

下一步(Next>),選擇自定義(Custom)安裝,如下圖所示 -

下一步(Next>),選擇安裝目錄為:D:\Program Files\MongoDB\Server\3.4\ ,如下圖所示 -

下一步(Next>),開始安裝 -

安裝過程中,如下圖所示 -

安裝完成,點擊:Finish,如下圖所示 -

運行MongoDB

注意:不要使 mongod.exe 在公共網(wǎng)絡上可見,而不使用“安全模式”進行認證設置。 MongoDB旨在在受信任的環(huán)境中運行,默認情況下數(shù)據(jù)庫不啟用“安全模式”。

MongoDB需要一個數(shù)據(jù)目錄來存儲所有數(shù)據(jù)。MongoDB的默認數(shù)據(jù)目錄路徑是從中啟動 MongoDB 的驅動器上的絕對路徑D:\Program Files\MongoDB\Server\3.4\data\db。通過在命令提示符中運行以下命令來創(chuàng)建此文件夾:

D:\Program Files\MongoDB\Server\3.4> "md D:\Program Files\MongoDB\Server\3.4\data"

可以使用--dbpath選項為mongod.exe指定數(shù)據(jù)文件的備用路徑,例如:

“D:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "D:\Program Files\MongoDB\Server\3.4\data\db"

啟動MongoDB

要啟動 MongoDB,請運行 mongod.exe 。 例如,從命令提示符:

“D:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"

注意:如果不使用 --dbpath 指定數(shù)據(jù)存儲的目錄,那么 MongoDB 默認使用的是 “C:\data\db“ 目錄,所以在啟動 MongoDB 數(shù)據(jù)庫之前要確保 “C:\data\db“ 目錄已經(jīng)創(chuàng)建了。

在執(zhí)行上面命令啟動后,應該會看到類似下面的輸出結果 -

C:\Users\Administrator>"D:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"
2017-06-29T02:37:46.688+0800 I CONTROL  [initandlisten] MongoDB starting : pid=10652 port=27017 dbpath=C:\data\db\ 64-bit host=MY-PC
2017-06-29T02:37:46.691+0800 I CONTROL  [initandlisten] targetMinOS: Windows
... ...
... ...
2017-06-29T02:37:46.733+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1491M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-06-29T02:37:47.738+0800 I CONTROL  [initandlisten]
2017-06-29T02:37:47.742+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-06-29T02:37:47.751+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-06-29T02:37:47.761+0800 I CONTROL  [initandlisten]
2017-06-29T02:37:48.315+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2017-06-29T02:37:48.659+0800 I INDEX    [initandlisten] build index on: admin.system.version properties: { v: 2, key: { version: 1 }, name: "incompatible_with_version_32", ns: "admin.system.version" }
2017-06-29T02:37:48.669+0800 I INDEX    [initandlisten]          building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2017-06-29T02:37:48.710+0800 I INDEX    [initandlisten] build index done.  scanned 0 total records. 0 secs
2017-06-29T02:37:48.718+0800 I COMMAND  [initandlisten] setting featureCompatibilityVersion to 3.4
2017-06-29T02:37:48.732+0800 I NETWORK  [thread1] waiting for connections on port 27017
2017-06-29T02:40:54.820+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:60285 #1 (1 connection now open)
2017-06-29T02:40:54.822+0800 I NETWORK  [conn1] received client metadata from 127.0.0.1:60285 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.5" }, os: { type: "Windows", name: "Microsoft Windows 8", architecture: "x86_64", version: "6.2 (build 9200)" } }
`

打開 MongoDB 客戶端測試使用

D:\Program Files\MongoDB\Server\3.4\bin> mongo.exe
MongoDB shell version v3.4.5
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.5
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
Server has startup warnings:
2017-06-29T02:37:47.738+0800 I CONTROL  [initandlisten]
2017-06-29T02:37:47.742+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-06-29T02:37:47.751+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-06-29T02:37:47.761+0800 I CONTROL  [initandlisten]
>
> db
test
> show dbs 
admin  0.000GB
local  0.000GB
>

MongoDB幫助

要獲取命令列表,請在MongoDB客戶端中鍵入:db.help()。 這將列出一個命令列表,如下面的屏幕截圖所示 -

> db.help()
DB methods:
        db.adminCommand(nameOrDocument) - switches to 'admin' db, and runs command [ just calls db.runCommand(...) ]
        db.auth(username, password)
        db.cloneDatabase(fromhost)
        db.commandHelp(name) returns the help for the command
        db.copyDatabase(fromdb, todb, fromhost)
        db.createCollection(name, { size : ..., capped : ..., max : ... } )
        db.createView(name, viewOn, [ { $operator: {...}}, ... ], { viewOptions } )
        db.createUser(userDocument)
        db.currentOp() displays currently executing operations in the db
        db.dropDatabase()
        db.eval() - deprecated
        db.fsyncLock() flush data to disk and lock server for backups
        db.fsyncUnlock() unlocks server following a db.fsyncLock()
        db.getCollection(cname) same as db['cname'] or db.cname
        db.getCollectionInfos([filter]) - returns a list that contains the names and options of the db's collections
        db.getCollectionNames()
        db.getLastError() - just returns the err msg string
        db.getLastErrorObj() - return full status object
        db.getLogComponents()
        db.getMongo() get the server connection object
        db.getMongo().setSlaveOk() allow queries on a replication slave server
        db.getName()
        db.getPrevError()
        db.getProfilingLevel() - deprecated
        db.getProfilingStatus() - returns if profiling is on and slow threshold
        db.getReplicationInfo()
        db.getSiblingDB(name) get the db at the same server as this one
        db.getWriteConcern() - returns the write concern used for any operations on this db, inherited from server object if set
        db.hostInfo() get details about the server's host
        db.isMaster() check replica primary status
        db.killOp(opid) kills the current operation in the db
        db.listCommands() lists all the db commands
        db.loadServerScripts() loads all the scripts in db.system.js
        db.logout()
        db.printCollectionStats()
        db.printReplicationInfo()
        db.printShardingStatus()
        db.printSlaveReplicationInfo()
        db.dropUser(username)
        db.repairDatabase()
        db.resetError()
        db.runCommand(cmdObj) run a database command.  if cmdObj is a string, turns it into { cmdObj : 1 }
        db.serverStatus()
        db.setLogLevel(level,<component>)
        db.setProfilingLevel(level,<slowms>) 0=off 1=slow 2=all
        db.setWriteConcern( <write concern doc> ) - sets the write concern for writes to the db
        db.unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the db
        db.setVerboseShell(flag) display extra information in shell output
        db.shutdownServer()
        db.stats()
        db.version() current version of the server
>

MongoDB統(tǒng)計

要獲取有關MongoDB服務器的統(tǒng)計信息,請在 MongoDB 客戶端中鍵入命令:db.stats()。 這個命令將顯示數(shù)據(jù)庫名稱,數(shù)據(jù)庫中的集合和文檔數(shù)量。命令的輸出如下面的截圖所示 -

> db.stats()
{
        "db" : "test",
        "collections" : 0,
        "views" : 0,
        "objects" : 0,
        "avgObjSize" : 0,
        "dataSize" : 0,
        "storageSize" : 0,
        "numExtents" : 0,
        "indexes" : 0,
        "indexSize" : 0,
        "fileSize" : 0,
        "ok" : 1
}
>

上一篇:MongoDB聚合下一篇:MongoDB分析查詢