- You can run MongoDB as a macOS service using brew, or you can run MongoDB manually as a background process. It is recommended to run MongoDB as a macOS service, as doing so sets the correct system ulimit values automatically (see ulimit settings for more information). To run MongoDB (i.e. The mongod process) as a macOS service, issue the following.
- First, download the most the latest stable release of the MongoDB for macOS. It’s the “macOS 64-bit x 64” option under “OS” on MongoDB’s Download Center. Here, the current release version of MongoDB and the macOS 64-bit x64 options are selected on the MongoDB Download Center’s website.
MongoDB only supports macOS versions 10.11 and later on Intel x86-64. Download the binary files for the desired release of MongoDB.¶ Download the binaries from. Here is the Manual Method to install MongoDB in MAC. 1.Download mongodb 'mongodb-osx-ssl-x8664-3.6.5.tgz' file. 2.Extract it using the command $ tar -zxvf mongodb-osx-ssl-x8664-3.6.5.tgz 3.Create a directory and copy the extracted contents to that $ mkdir mongodb $ cp -R -n mongodb-osx-ssl-x8664-3.6.5.tgz/ mongodb.
- Install MongoDB
Author: MongoDB Documentation Team
This guide describes how to install MongoDB locally. If you wouldlike to use MongoDB in the Cloud using Atlas
, our manageddatabase product, see Get Started with Atlas.
Time required: 10 minutes
What You’ll Need¶
MongoDB supports a variety of 64-bit platforms. Refer to theSupported Platforms table toverify that MongoDB is supported on the platform to which you wishto install it.
Procedure¶
Install MongoDB¶
- Windows
- macOS
- Linux
Download the binaries from the MongoDB Download Center.
Open Windows Explorer/File Explorer.
Change the directory path to where you downloaded the MongoDB
.msi
file. By default, this is%HOMEPATH%Downloads
.Double-click the
.msi
file.The Windows Installer guides you through the installation process.
If you choose the Custom installation option, you mayspecify an installation directory.
MongoDB does not have any other system dependencies. You can install and run MongoDB from any folder you choose.
Note
This tutorial assumes that you installed MongoDBin
C:ProgramFilesMongoDBServer4.2
.
Platform Support
MongoDB only supports macOS versions 10.11 and later on Intel x86-64.
Download the binary files for the desired release of MongoDB.¶
Download the binaries from the MongoDB Download Center.
Extract the files from the downloaded archive.¶
For example, from a system shell, you can extract through the tar
command:
Copy the extracted archive to the target directory.¶
Copy the extracted folder to the location from which MongoDB will run.
Ensure the location of the binaries is in the PATH
variable.¶
The MongoDB binaries are in the bin/
directory of the archive. Toensure that the binaries are in your PATH
, you can modify yourPATH
.
Download Mongodb Macos Download
For example, you can add the following line to your shell’src
file (e.g. ~/.bashrc
):
Replace <mongodb-install-directory>
with the path to the extractedMongoDB archive.
Download Mongodb Macos Command
Note
These instructions are for installing MongoDB directly froman archive file. If you would rather use your linuxdistribution’s package manager, refer to theinstallation instructions for yourdistribution in the MongoDB Manual.
Download the binary files for the desired release of MongoDB.¶
Download the binaries from the MongoDB Download Center.
Extract the files from the downloaded archive.¶
Extract the archive by double-clicking on the tar file or usingthe tar
command from the command line, as in the following:
Copy the extracted archive to the target directory.¶
Copy the extracted folder to the location from which MongoDB will run.
Ensure the location of the binaries is in the PATH
variable.¶
The MongoDB binaries are in the bin/
directory of the archive. Toensure that the binaries are in your PATH
, you can modify yourPATH
.
For example, you can add the following line to your shell’src
file (e.g. ~/.bashrc
):
Replace <mongodb-install-directory>
with the path to the extractedMongoDB archive.
Run MongoDB¶
- Windows
- macOS
- Linux
Warning
Do not make mongod.exe
visible on publicnetworks without running in “Secure Mode” with theauth
setting. MongoDB is designed to be run intrusted environments, and the database does not enable“Secure Mode” by default.
Set up the MongoDB environment.¶
MongoDB requires a data directory to store alldata. MongoDB’s default data directory path is the absolute pathdatadb
on the drive from which you start MongoDB. Createthis folder by running the following command in aCommand Prompt:
You can specify an alternate path for data files using the--dbpath
option tomongod.exe
, for example:
If your path includes spaces, enclose the entire path in doublequotes, for example:
You may also specify the dbpath
in a configuration file.
Start MongoDB.¶
To start MongoDB, run mongod.exe
. For example, from theCommand Prompt:
This starts the main MongoDB database process. The waitingforconnections
message in the console output indicates that themongod.exe
process is running successfully.
Depending on the security level of your system, Windows may pop up aSecurity Alert dialog box about blocking “some features” ofC:ProgramFilesMongoDBServer4.0binmongod.exe
from communicatingon networks. All users should select PrivateNetworks,suchasmyhomeorworknetwork
and click Allowaccess
. For additional information onsecurity and MongoDB, please see the Security Documentation.
Verify that MongoDB has started successfully¶
Verify that MongoDB has started successfully bychecking the process output for the following line:
The output should be visible in the terminal or shell window.
You may see non-critical warnings in the processoutput. As long as you see the log line shown above, you can safelyignore these warnings during your initial evaluation of MongoDB.
Connect to MongoDB.¶
To connect to MongoDB through the ~bin.mongo.exe
shell,open another Command Prompt.
Create the data directory¶
Before you start MongoDB for the first time, create the directory towhich the mongod
process will write data. By default, themongod
process uses the /data/db
directory. If you createa directory other than this one, you must specify that directory in thedbpath
option when starting the mongod
processlater in this procedure.
The following example command creates the default /data/db
directory:
Set permissions for the data directory¶
Before running mongod
for the first time, ensure that theuser account running mongod
has read and write permissionsfor the directory.
Run MongoDB¶
To run MongoDB, run the mongod
process at the system prompt.If necessary, specify the path of the mongod
or the datadirectory. See the following examples.
Run without specifying paths¶
If your system PATH
variable includes the location of themongod
binary and if you use the default data directory(i.e., /data/db
), simply enter mongod
at the system prompt:
Specify the path of the mongod
¶
If your PATH
does not include the location of themongod
binary, enter the full path to the mongod
binary at the system prompt:
Specify the path of the data directory¶
If you do not use the default data directory (i.e., /data/db
),specify the path to the data directory using the--dbpath
option:
Verify that MongoDB has started successfully¶
Verify that MongoDB has started successfully bychecking the process output for the following line:
The output should be visible in the terminal or shell window.
You may see non-critical warnings in the processoutput. As long as you see the log line shown above, you can safelyignore these warnings during your initial evaluation of MongoDB.
Important
If you are using SELinux on a Red Hat Linux-based system,(Red Hat Enterprise Linux or CentOS Linux), you mustconfigure SELinux to allow MongoDB to start. Refer toConfigure SELinux for instructions.
Create the data directory¶
Before you start MongoDB for the first time, create the directory towhich the mongod
process will write data. By default, themongod
process uses the /data/db
directory. If you createa directory other than this one, you must specify that directory in thedbpath
option when starting the mongod
processlater in this procedure.
The following example command creates the default /data/db
directory:
Set permissions for the data directory¶
Before running mongod
for the first time, ensure that theuser account running mongod
has read and write permissionsfor the directory.
Run MongoDB¶
To run MongoDB, run the mongod
process at the system prompt.If necessary, specify the path of the mongod
or the datadirectory. See the following examples.
Run without specifying paths¶
If your system PATH
variable includes the location of themongod
binary and if you use the default data directory(i.e., /data/db
), simply enter mongod
at the system prompt:
Specify the path of the mongod
¶
If your PATH
does not include the location of themongod
binary, enter the full path to the mongod
binary at the system prompt:
Specify the path of the data directory¶
If you do not use the default data directory (i.e., /data/db
),specify the path to the data directory using the--dbpath
option:
Verify that MongoDB has started successfully¶
Verify that MongoDB has started successfully bychecking the process output for the following line:
The output should be visible in the terminal or shell window.
You may see non-critical warnings in the processoutput. As long as you see the log line shown above, you can safelyignore these warnings during your initial evaluation of MongoDB.
Summary¶
If you have successfully completed this guide, you have installedMongoDB and are ready to connect to your mongod
instance and start inserting data.
What’s Next¶
The next guide walks you through setting up authentication on your new MongoDB instance.
Mongodb Download Mac
See Also¶
- Structure your Data for MongoDB for an introduction to MongoDB.
- Installation for installation instructionsfor MongoDB Enterprise Edition, details on installing olderversions of MongoDB.
© MongoDB, Inc 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.
1、 Installation
To download and install the official website, you need to input the mailbox and other information. You can use the command line to install. The MAC is installed as follows
More installation methods can refer to rookie tutorial
After the installation, set the environment variables to add the mongodb binary command file directory to the path
Enter the following command in the terminal
2、 Start
The default path for mongodb data storage is / data / DB(i.e. under the root directory / data / DB), but the directory does not necessarily exist on your computer and can be created manually
Start directly from the command line
At this time, I found that/Data / DB is read-onlyBecause the database needs to read and write data, if you do not have root permission, the folder created under the root directory does not have write permission by default. It can be modified by the following command
If you want to bypass the permission problem, you can also not create a data folder in the root directory!!!
Enter the command again
If you see it
Proves that the service was started successfully.
3、 Operation
After starting mongodb service, the current command panel cannot perform other operations. Open a new command panel. Enter the following command to enter the operation mode
4、 Command
Well, a brief introduction to here ~ welcome to leave a message to exchange and supplement~