Install MongoDB Enterprise on macOS
Overview
Use this tutorial to manually install MongoDB 8.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.
MongoDB Version
This tutorial installs MongoDB 8.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.
Considerations
MongoDB Shell, mongosh
When you use the .tgz
package to install the server, you need to
follow the mongosh installation instructions to
download and install mongosh separately.
Platform Support
MongoDB 8.0 Enterprise Edition supports macOS 11 or later.
For more information, see Platform Support.
Production Notes
Before deploying MongoDB in a production environment, consider the Production Notes for Self-Managed Deployments document which offers performance considerations and configuration recommendations for production MongoDB deployments.
Install MongoDB Enterprise Edition
To manually install MongoDB Enterprise Edition from the .tgz
, select the tab
that corresponds with your Mac's processor and complete the following steps:
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
PATH
variable, such as/usr/local/bin
. Replace/path/to/the/mongodb-directory/
with your installation directory.123Ensure 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
PATH
variable, such as/usr/local/bin
. Replace/path/to/the/mongodb-directory/
with your installation directory.1Create the data directory.
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
~/data/db
directory:sudo mkdir -p ~/data/db 23Set permissions for the data and log directories.
Ensure that the user account running
mongod
has read and write permissions for these two directories. If you are runningmongod
as your own user account, and you just created the two directories above, they should already accessible to your user. Otherwise, you can usechown
to set ownership, substituting the appropriate user:sudo chown <user> ~/data/db sudo chown <user> ~/data/log/mongodb 4Run MongoDB.
To run MongoDB, run the
mongod
process at the system prompt, providing the two parametersdbpath
andlogpath
from above, and thefork
parameter to runmongod
in the background. Alternatively, you may choose to store the values fordbpath
,logpath
,fork
, and many other parameters in a configuration file.Run
mongod
with command-line parametersRun the
mongod
process at the system prompt, providing the three necessary parameters directly on the command-line:mongod --dbpath ~/data/db --logpath ~/data/log/mongodb/mongo.log --fork Run
mongod
with a configuration fileRun the
mongod
process at the system prompt, providing the path to a configuration file with theconfig
parameter:mongod --config /usr/local/etc/mongod.conf macOS may prevent
mongod
from running after installation. If you receive a security error when startingmongod
indicating that the developer could not be identified or verified, do the following to grantmongod
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.
56Begin using MongoDB.
Start a
mongosh
session on the same host machine as themongod
. You can runmongosh
without any command-line options to connect to amongod
that is running on your localhost with the default port of 27017:mongosh For more information on connecting using
mongosh
, such as to connect to amongod
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 with MongoDB for the available editions.
Additional Information
Localhost Binding by Default
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:
Warning
Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist for Self-Managed Deployments. At minimum, consider enabling authentication and hardening network infrastructure.
For more information on configuring bindIp
, see
IP Binding in Self-Managed Deployments.