安裝
嘗試一:手動命令安裝
嘗試二:採用Homebrew
嘗試三:下載安裝包
使用
安裝
嘗試一:手動命令安裝
按照官網https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/說明,手動命令安裝html
1.下載所需版本的MongoDB的二進制文件mongodb
curl -O https://fastdl.mongodb.org/osx-ssl/mongodb-osx-ssl-x86_64-3.4.10.tgz
2.解壓數據庫
tar -zxvf mongodb-osx-ssl-x86_64-3.4.10.tgz
報錯:緩存
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
試過不少方法都沒有解決,後續找到解決方法再更。。bash
嘗試二:採用Homebrew
首先得安裝Homebrew,結果安裝Homebrew時失敗。。。
報錯:curl
Error: Checksum mismatch.
...
To retry an incomplete download, remove the file above.
Error: Failed to install vendor Ruby.ui
而後過了一夜,次日重試了一次一把就安裝上了、、、莫名其妙、、、url
查看home-brew版本:.net
brew -v
安裝以前先更新命令行
brew update
安裝
brew install mongodb --with-openssl
安裝的過程當中遇到下載失敗的問題,請參考:
http://www.jianshu.com/p/ac4b23c4ebab
命令 做用
brew --cache 查看brew緩存地址
mongod -version 查看mongodb版本
嘗試三:下載安裝包
下載連接:https://www.mongodb.com/download-center#community
參考:https://www.cnblogs.com/quickcodes/p/5390482.html
命令 做用
open -e ~/.bash_profile 打開配置環境變量的文件
source ~/.bash_profile 使配置生效
使用
啓動和中止mongodb數據庫
方法一:使用bash終端
啓動
mongod --config /usr/local/etc/mongod.conf # 啓動
或
mongod --dbpath . # 啓動
啓動成功後能夠在mac的「活動監視器」中看到進程mongod,中止則關閉進程。
中止:
使用command+T在同一窗口中創建多標籤終端,在新的bash中輸入:
mongo # 進入mongo命令行
> use admin
> db.shutdownServer() # 中止
> ctrl+C # 退出mongo命令行
進入mongo命令行能夠在mac的「活動監視器」中看到進程mongo,退出則關閉進程。
方法二:使用homebrew
brew services start mongodb # 啓動brew services stop mongodb # 中止轉自https://blog.csdn.net/tymatlab/article/details/78532176