MongoDB/Install:修订间差异
来自康健生活
| (未显示同一用户的9个中间版本) | |||
| 第1行: | 第1行: | ||
== 引言 == | == 引言 == | ||
== 安装 == | == 安装 == | ||
=== mac === | |||
==== brew ==== | |||
{{shc|<syntaxhighlight lang="bash"> | |||
brew update</syntaxhighlight>|➜ ~}} | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
brew tap mongodb/brew</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
Running `brew update --preinstall`... | |||
==> Auto-updated Homebrew! | |||
Updated 1 tap (homebrew/cask). | |||
==> Updated Casks | |||
Updated 3 casks. | |||
==> Tapping mongodb/brew | |||
Cloning into '/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew'... | |||
remote: Enumerating objects: 846, done. | |||
remote: Counting objects: 100% (343/343), done. | |||
remote: Compressing objects: 100% (254/254), done. | |||
remote: Total 846 (delta 179), reused 144 (delta 86), pack-reused 503 | |||
Receiving objects: 100% (846/846), 185.40 KiB | 246.00 KiB/s, done. | |||
Resolving deltas: 100% (417/417), done. | |||
Tapped 14 formulae (30 files, 252KB). | |||
</syntaxhighlight>|➜ ~}} | |||
开始安装。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
brew install mongodb-community</syntaxhighlight>|➜ ~}} | |||
执行到这里,我遇到了一个错误。<code>Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins</code>。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
sudo chown -R $(whoami) $(brew --prefix)/* | |||
</syntaxhighlight>|➜ ~}} | |||
再执行。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
brew reinstall mongodb-community | |||
</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.6.tgz | |||
Already downloaded: /Users/kangjian/Library/Caches/Homebrew/downloads/6d6c69ce66861b3aac721c356f0d9560ccd34acc1b74b7ff669532fbebf8cc0c--mongodb-macos-x86_64-5.0.6.tgz | |||
==> Reinstalling mongodb/brew/mongodb-community | |||
==> Caveats | |||
To 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/5.0.6: 11 files, 181.5MB, built in 5 seconds | |||
==> `brew cleanup` has not been run in the last 30 days, running now... | |||
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. | |||
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). | |||
Pruned 3 symbolic links and 4 directories from /usr/local | |||
</syntaxhighlight>|➜ ~}} | |||
运行 mongo。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
brew services start mongodb-community | |||
</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community) | |||
</syntaxhighlight>|➜ ~}} | |||
停止 mongo。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
brew services stop mongodb-community | |||
</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
Stopping `mongodb-community`... (might take a while) | |||
==> Successfully stopped `mongodb-community` (label: homebrew.mxcl.mongodb-community) | |||
</syntaxhighlight>|➜ ~}} | |||
=== Windows === | === Windows === | ||
环境变量 | 环境变量 | ||
| 第67行: | 第130行: | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
systemctl restart mongod.service</syntaxhighlight>|#}} | systemctl restart mongod.service</syntaxhighlight>|#}} | ||
=== docker === | |||
{{shc|<syntaxhighlight lang="bash"> | |||
sudo docker pull mongo:latest</syntaxhighlight>|$|/home/kangkk}} | |||
{{shc|<syntaxhighlight lang="bash"> | |||
sudo docker run -d -p 27017:27017 --name mongo -e --privileged=true MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD='kangjian' mongo:latest</syntaxhighlight>|$|/home/kangkk}} | |||
== 创建 == | == 创建 == | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||