此外你还可以使用 OSX 的 brew 来安装 mongodb: brew tap mongodb/brew brew install mongodb-community@4.4 @ 符号后面的 4.4 是最新版本号。 安装信息:.

MongoDB Atlasis a hosted MongoDB service option in the cloud which requires noinstallation overhead and offers a free tier to get started.

Overview¶

  • Install Homebrew¶. MacOS does not include the Homebrew brew package by default. Install brew using the official Homebrew installation instructions.; Installing MongoDB 4.4 Community Edition¶. Follow these steps to install MongoDB Community Edition using Homebrew's brew package manager. Be sure that you have followed the installation prerequisites above before proceeding.
  • Mongodb mac安装Today we will install MongoDB on Mac OS X. MongoDB is one of the leading NoSQL database. MySql and Oracle are termed as “Relation Databases”.

Use this tutorial to manually install MongoDB 4.4 CommunityEdition on macOS using a downloaded .tgz tarball.

MongoDB Version¶

This tutorial installs MongoDB 4.4 CommunityEdition. To install a different version of MongoDB Community,use the version drop-down menu in the upper-left corner of this page toselect the documentation for that version.

Installation Method¶

While MongoDB can be installed manually via a downloaded .tgztarball as described in this document, it is recommended to use thebrew package manager on your system to install MongoDB ifpossible. Using a package manager automatically installs all neededdependencies, provides an example mongod.conf file to get youstarted, and simplifies future upgrade and maintenance tasks.

➤ See Install MongoDB using the brew Package Managerfor instructions.

Considerations¶

Platform Support¶

MongoDB 4.4 Community Edition supports macOS 10.13 or later.

See Supported Platforms for more information.

Production Notes¶

Before deploying MongoDB in a production environment, consider theProduction Notes document which offersperformance considerations and configuration recommendations forproduction MongoDB deployments.

Install MongoDB Community Edition¶

Follow these steps to manually install MongoDB Community Edition fromthe .tgz.

Download the tarball.¶

Download the MongoDB Communitytgz tarball from the followinglink:

➤MongoDB Download Center

  1. In the Version dropdown, select the version ofMongoDB to download.
  2. In the Platform dropdown, select macOS.
  3. In the Package dropdown, select tgz.
  4. Click Download.

Extract the files from the downloaded archive.¶

If your web browser automatically unzips the file as part of thedownload, the file would end in .tar instead.

Ensure the binaries are in a directory listed in your PATH environment variable.¶

The MongoDB binaries are in the bin/ directory of the tarball.You can either:

  • Copy the binaries into a directory listed in your PATHvariable, such as /usr/local/bin (Update/path/to/the/mongodb-directory/ with your installationdirectory as appropriate)

  • Create symbolic links to the binaries from a directory listed inyour PATH variable, such as /usr/local/bin (Update/path/to/the/mongodb-directory/ with your installationdirectory as appropriate):

Run MongoDB Community Edition¶

ulimit Considerations
Most Unix-like operating systems limit the system resources that aprocess may use. These limits may negatively impact MongoDB operation,and should be adjusted. See UNIX ulimit Settings for the recommendedsettings for your platform.
Starting in MongoDB 4.4, a startup error is generated if theulimit value for number of open files is under 64000.

Procedure¶

Follow these steps to run MongoDB Community Edition. These instructionsassume that you are using the default settings.

Create the data directory.¶

Before you start MongoDB for the first time, you must create thedirectory to which the mongod process will write data.

For example, to create the /usr/local/var/mongodb directory:

Starting with macOS 10.15 Catalina, Apple restricts access to theMongoDB default data directory of /data/db. On macOS 10.15Catalina, you must use a different data directory, such as/usr/local/var/mongodb.

Create the log directory.¶

You must also create the directory in which the mongod processwill write its log file:

For example, to create the /usr/local/var/log/mongodb directory:

Hongo

Set permissions for the data and log directories.¶

Ensure that the user account running mongod has readand write permissions for these two directories. If you are runningmongod as your own user account, and you just createdthe two directories above, they should already accessible to youruser. Otherwise, you can use chown to set ownership,substituting the appropriate user:

Run MongoDB.¶

To run MongoDB, run the mongod process at the systemprompt, providing the two parameters dbpath and logpathfrom above, and the fork parameter to run mongodin the background. Alternatively, you may choose to store the valuesfor dbpath, logpath, fork, and many other parameters in aconfiguration file.

Run mongod with command-line parameters¶

Run the mongod process at the system prompt,providing the three necessary parameters directly on thecommand-line:

Run mongod with a configuration file¶

Run the mongod process at the system prompt,providing the path to aconfiguration filewith the config parameter:

macOS may prevent mongod from running after installation. Ifyou receive a security error when starting mongodindicating that the developer could not be identified or verified,do the following to grant mongod access to run:

  • Open System Preferences
  • Select the Security and Privacy pane.
  • Under the General tab, click the button to the right of themessage about mongod, labelled either OpenAnyway or Allow Anyway depending on your version ofmacOS.

Verify that MongoDB has started successfully.¶

Verify that MongoDB has started successfully:

If you do not see a mongod process running, check the logfile forany error messages.

Hongo Mac Os Catalina

Begin using MongoDB.¶

Start a mongo shell on the same host machine as themongod. You can run the mongo shellwithout any command-line options to connect to amongod that is running on your localhost with thedefault port of 27017:

macOS may prevent the mongo shell from running after installation. Ifyou receive a security error when starting the mongo shellindicating that the developer could not be identified or verified,do the following to grant the mongo shell access to run:

  • Open System Preferences
  • Select the Security and Privacy pane.
  • Under the General tab, click the button to the right of themessage about the mongo shell, labelled either OpenAnyway or Allow Anyway depending on your version ofmacOS.

For more information on connecting using the mongoshell, such as to connect to a mongod instance runningon a different host and/or port, see The mongo Shell.

To help you start using MongoDB, MongoDB provides GettingStarted Guides in various driver editions. SeeGetting Started for the available editions.

Additional Information¶

Localhost Binding by Default¶

By default, MongoDB launches with bindIp set to127.0.0.1, which binds to the localhost network interface. Thismeans that the mongod can only accept connections fromclients that are running on the same machine. Remote clients will not beable to connect to the mongod, and the mongod willnot be able to initialize a replica set unless this value is setto a valid network interface.

This value can be configured either:

  • in the MongoDB configuration file with bindIp, or
  • via the command-line argument --bind_ip

Before binding to a non-localhost (e.g. publicly accessible)IP address, ensure you have secured your cluster from unauthorizedaccess. For a complete list of security recommendations, seeSecurity Checklist. At minimum, considerenabling authentication andhardening network infrastructure.

For more information on configuring bindIp, seeIP Binding.

© MongoDB, Inc 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.

Install MongoDB Community Edition on macOSInstall MongoDB Community Edition on Windows

Hongo Mac Os Catalina

MongoDB is a fully flexible index support and rich queries database. It is a NoSQL database. MongoDB 4.0 supports multi-document ACID transactions. This tutorial will help you to install MongoDB database server on macOS. After the installation, you may also like our MongoDB tutorial.

Prerequisites

Mac Os Catalina

  • Terminal: You must have macOS terminal access and little knowledge about working with the command line.
  • Homebrew: Homebrew is a popular package management tools used for installing most open source software like Node. Here is the Homebrew installation tutorial

Install MongoDB on MacOS

First of all, update the Homebrew package repository index. Then install MongoDB using homebrew installer. This will install MongoDB at location /usr/local/Cellar/mongodb.

Start/Stop MongoDB

Start MongoDB – Use the following command to start MongoDB from a terminal. Make sure to change 4.0.3_1 in below command with the installed version of MongoDB on your macOS.

Hongo Mac Os 11

Stop MongoDB – Simply use the unload options to stop running MongoDB database service on macOS.

Hongo Mac Os X

Working with MongoDB

After starting MongoDB service, just type “mongo” on the terminal. This will connect to MongoDB service running on the local system.

You can visit our MongoDB tutorial section to read and understand working with MongoDB.