将MongoDB Community Edition安装在macOS Sierra 10.12上
前提 tí) – Premise or prerequisite
家庭酿造已安装
步骤 (bù
在Homebrew上安装mongoDB。
Last login: Sat Apr 27 14:57:37 on ttys001
xxxxxx-no-MBP:~ xxxxxx$ brew install mongodb-community@4.0
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
ballerina ghq istioctl neovim
ccache iamy mysql swiftlint
Error: No available formula with the name "mongodb-community@4.0"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
找不到名为mongodb-community@4.0的配方。
我正在寻找一个在一个月内被删除的配方。
2. 好像需要先点击一下才行
xxxxxx-no-MBP:~ xxxxxx$ brew tap mongodb/brew
==> Tapping mongodb/brew
Cloning into '/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 12 (delta 3), reused 9 (delta 2), pack-reused 0
Unpacking objects: 100% (12/12), done.
Tapped 5 formulae (42 files, 56.3KB).
再次通过Homebrew安装mongoDB。
xxxxxx-no-MBP:~ xxxxxx$ brew install mongodb-community@4.0
==> Installing mongodb-community from mongodb/brew
==> Downloading https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-4.0.9.tgz
######################################################################## 100.0%
==> Caveats
To have launchd start mongodb/brew/mongodb-community now and restart at login:
brew services start mongodb/brew/mongodb-community
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary
? /usr/local/Cellar/mongodb-community/4.0.9: 20 files, 221.0MB, built in 18 seconds
将MongoDB作为服务启动。
据我所知,有多种方法可以将其作为服务运行。
xxxxxx-no-MBP:~ xxxxxx$ brew services start mongodb-community@4.0
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 17 (delta 0), reused 12 (delta 0), pack-reused 0
Unpacking objects: 100% (17/17), done.
Tapped 1 command (49 files, 59.5KB).
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
尝试运行 mongo 命令。
xxxxxx-no-MBP:~ xxxxxx$ mongo
MongoDB shell version v4.0.9
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("8918730f-4190-4313-8e3c-78adb2cffb63") }
MongoDB server version: 4.0.9
Server has startup warnings:
2019-04-29T19:32:53.305+0900 I CONTROL [initandlisten]
2019-04-29T19:32:53.305+0900 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-04-29T19:32:53.305+0900 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-04-29T19:32:53.306+0900 I CONTROL [initandlisten]
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
展示数据库的内容
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
>
关于术语
公式:软件包定义
点击:一个存放公式和/或命令的Git代码库
请参考
https://qiita.com/saa/items/85ed5e914d424fbf9fd6 -> 在这个链接里,提供了关于某个问题的详细解决方案。
https://qiita.com/wkentaro/items/d4981582e08b134f1e1d -> 这个链接中介绍了一个有用的工具,能够完成特定任务。
http://tweeeety.hateblo.jp/entry/2018/05/04/181928 -> 这个链接里记录了作者对某一主题的观点和见解。