Docs Menu

Install MongoDB Enterprise on macOS

On this page

  • Overview
  • Considerations
  • Install MongoDB Enterprise Edition
  • Run MongoDB Enterprise Edition
  • Additional Information
Note
MongoDB Atlas

MongoDB Atlas is a hosted MongoDB service option in the cloud which requires no installation overhead and offers a free tier to get started.

Use this tutorial to manually install MongoDB 5.0 Enterprise Edition on macOS using a downloaded .tgz tarball.

MongoDB Enterprise Edition is available on select platforms and contains support for several features related to security and monitoring.

This tutorial installs MongoDB 5.0 Enterprise Edition. To install a different version of MongoDB Enterprise, use the version drop-down menu in the upper-left corner of this page to select the documentation for that version.

When you use the .tgz package to install the server, you need to follow the mongosh installation instructions to download and install mongosh separately.

Note
EOL Notice
  • MongoDB 5.0 Enterprise Edition removes support for macOS 10.13

MongoDB 5.0 Enterprise Edition supports macOS 10.14 or later.

See Supported Platforms for more information.

Before deploying MongoDB in a production environment, consider the Production Notes document which offers performance considerations and configuration recommendations for production MongoDB deployments.

Follow these steps to manually install MongoDB Enterprise Edition from the .tgz.

1

Download the MongoDB Enterprise tgz tarball from the following link:

MongoDB Download Center

  1. In the Version dropdown, select the version of MongoDB to download.
  2. In the Platform dropdown, select macOS.
  3. In the Package dropdown, select tgz.
  4. Click Download.
2
tar -zxvf mongodb-macos-x86_64-enterprise-5.0.tgz

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

3

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

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

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

    sudo ln -s /path/to/the/mongodb-directory/bin/* /usr/local/bin/
ulimit Considerations
Most Unix-like operating systems limit the system resources that a process may use. These limits may negatively impact MongoDB operation, and should be adjusted. See UNIX ulimit Settings for the recommended settings for your platform.
Note
Starting in MongoDB 4.4, a startup error is generated if the ulimit value for number of open files is under 64000.

Follow these steps to run MongoDB Enterprise Edition. These instructions assume that you are using the default settings.

1

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

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

sudo mkdir -p /usr/local/var/mongodb
Important

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

2

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

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

sudo mkdir -p /usr/local/var/log/mongodb
3

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

sudo chown my_mongodb_user /usr/local/var/mongodb
sudo chown my_mongodb_user /usr/local/var/log/mongodb
4

To run MongoDB, run the mongod process at the system prompt, providing the two parameters dbpath and logpath from above, and the fork parameter to run mongod in the background. Alternatively, you may choose to store the values for dbpath, logpath, fork, and many other parameters in a configuration file.

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

mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork

Run the mongod process at the system prompt, providing the path to a configuration file with the config parameter:

mongod --config /usr/local/etc/mongod.conf
Note
macOS Prevents mongod From Opening

macOS may prevent mongod from running after installation. If you receive a security error when starting mongod indicating 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 the message about mongod, labelled either Open Anyway or Allow Anyway depending on your version of macOS.
5

Verify that MongoDB has started successfully:

ps aux | grep -v grep | grep mongod

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

6

Start a mongosh session on the same host machine as the mongod. You can run mongosh without any command-line options to connect to a mongod that is running on your localhost with the default port of 27017:

mongosh
Note
macOS Prevents mongosh From Opening

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

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

For more information on connecting using mongosh, such as to connect to a mongod instance running on a different host and/or port, see the mongosh documentation.

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

By default, MongoDB launches with bindIp set to 127.0.0.1, which binds to the localhost network interface. This means that the mongod can only accept connections from clients that are running on the same machine. Remote clients will not be able to connect to the mongod, and the mongod will not be able to initialize a replica set unless this value is set to 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
Warning

Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.

For more information on configuring bindIp, see IP Binding.

Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.