下載
https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.3.tgz
解壓
$ sudo tar -zvf mongodb-macos-x86_64-4.2.3.tgz
重命名爲mongodb,移動到/usr/local/,添加到PATH
$ export PATH=/usr/local/mongodb/bin:$PATH
運行
創建數據庫存儲目錄/data/db
$ sudo mkdir -p /data/db
*sudo mkdir -p /data/db時報了Read-only file system,Mac系統升級所致
重新指定自定義數據庫存儲目錄
$ sudo mongod --dbpath=/data/db
*命令行每次啓動服務要重新指定
啓動服務
$ sudo mongod
新開終端執行命令:
$ ./mongo
MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
WARNING: No implicit session: Logical Sessions are only supported on server versions 3.6 and greater.
Implicit session: dummy session
MongoDB server version: 3.2.4
WARNING: shell and server versions do not match
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:
2020-03-22T15:54:23.861+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-03-22T15:54:23.861+0800 I CONTROL [initandlisten]
> 1+1
2
>
顯示如上信息並輸入1+1輸出2及安裝運行成功
可視化工具下載使用
設置Privacy Settings > close後
主界面選擇Fill in connection fields individually > connect
*記得先啓動服務