在Mac上安装最新版本的MongoDB并进行初始设置

总结

以下是将二进制文件安装MongoDB到Mac的步骤摘要。

行动环境

macOS High Sierra (版本10.13.6)

安装步骤

    • MongoDB公式サイトからファイル一式をダウンロード

 

    • バイナリーファイルの移動

 

    • データ/ログフォルダの生成

 

    起動

从MongoDB官方网站下载完整的文件套件。

从MongoDB的官方网站(https://www.mongodb.com/download-center#community)下载所需的文件。

wget https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-4.0.0.tgz

tar -zxvf mongodb-osx-ssl-x86_64-4.0.0.tgz  #フォルダを解凍する

移动二进制文件

将解压后的文件夹中的bin文件夹中的二进制文件移动到/usr/local/bin。

将名为***的文件移动到/usr/local/bin。

mv *** /usr/local/bin 

生成数据/日志文件夹

sudo mkdir /var/lib/mongodb
sudo touch /var/log/mongodb.log

创建用于存储数据的文件夹,并生成用于输出日志的文件。

开始运行

指定先前创建的数据存储目录和日志文件,启动数据库中的MongoDB。启动后终端将进入等待状态。

sudo mongod --dbpath /var/lib/mongodb --logpath /var/log/mongodb.log

打开另一个终端,并启动客户端端的mongo。

$ mongo
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.0
Server has startup warnings:
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten]
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten]
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten]
---
Enable MongoDB's free cloud-based monitoring service to collect 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 created for you. Anyone you share the URL with will also be able to
view this page. 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()
---

>

我成功启动,并成功安装了最新版本的MongoDB v4.0。

请参考MongoDB官方网站:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

广告
将在 10 秒后关闭
bannerAds