Windows MongoDB 安裝

下載

先獲取電腦版本,可知個人電腦64位,64位的MongoDB是不能運行在32位系統上的php

$ wmic os get caption
Caption
Microsoft Windows 7 Professional
$ wmic os get osarchitecture
OSArchitecture
64-bit

連接 https://www.mongodb.com/downl... 或者直接點擊 http://oaq0p7t2g.bkt.clouddn.... 下載html

啓動

創建配置文件mongo.conflaravel

vi mongo.conf
#數據庫路徑
dbpath=D:\mongo\data
#日誌輸出文件路徑
logpath=D:\mongo\log\mongodb.log
#錯誤日誌採用追加模式
logappend=true
#啓用日誌文件,默認啓用
journal=true
#這個選項能夠過濾掉一些無用的日誌信息,若須要調試使用請設置爲false
quiet=true
#端口號 默認爲27017
port=27017

進入cmd執行文件目錄,用管理員身份運行(重要)git

C:\windows\system32>mongod --remove --serviceName "MongoDB"
2018-08-13T17:26:12.069+0800 I CONTROL  [main] Trying to remove Windows service
'MongoDB'
2018-08-13T17:26:12.070+0800 I CONTROL  [main] Service 'MongoDB' removed

C:\windows\system32>mongod --config "D:\mongo\mongo.conf" --install --serviceNam
e "MongoDB"

C:\windows\system32>net start MongoDB
MongoDB 服務正在啓動 ..
MongoDB 服務已經啓動成功。
C:\windows\system32>mongo
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
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:
2018-08-13T17:26:44.632+0800 I CONTROL  [initandlisten]
2018-08-13T17:26:44.632+0800 I CONTROL  [initandlisten] ** WARNING: Access contr
ol is not enabled for the database.
2018-08-13T17:26:44.632+0800 I CONTROL  [initandlisten] **          Read and wri
te access to data and configuration is unrestricted.
2018-08-13T17:26:44.632+0800 I CONTROL  [initandlisten]
> show dbs
admin  0.000GB
local  0.000GB

任務管理器能夠查看到
filegithub

工具

圖形化工具 https://adminmongo.markmoffat... https://github.com/mrvautin/a...
Robomongo http://blog.robomongo.org/rob...mongodb

安裝PHP MongoDB擴展

由於用到 https://packagist.org/package... 這個包,
去網站http://php.net/manual/en/mong... http://pecl.php.net/package/m... 選擇對應版本
http://pecl.php.net/package/m... 我用的PHP7.1 選擇 https://windows.php.net/downl... 下載後修改 php.ini
須要注意的是 當你使用 find 時,這個方法會自動把參數轉換成 ObjectId https://laravel-china.org/top...
Order::where('id','201805301502401358078994')->first(); 替換 $order=Order::find('201805301502401358078994');shell

參考

https://vxhly.github.io/2017/...
https://segmentfault.com/a/11...
http://wiki.jikexueyuan.com/p...
http://www.runoob.com/mongodb...
https://segmentfault.com/a/11...
升級PHP7操做MongoDB
php mongodb
PHP7之Mongodb的開發詳解
入門教程
中文文檔數據庫

相關文章
相關標籤/搜索