The mongod Address is already in use. The mongod Address is already in use. The mongod Address is already in use. The other is “dbpath /data/db”.

To look a lot of information on the Internet, because a lot of document is this copy that, the copy of this, finally didn’t also the actual problem solving, waste a lot of time, so I just registered an account book, Jane his problems, and the final solution, because I also is a small white one, so know beginners in learning because it is very simple Settings, I don’t know, it’s going to take a lot of detours, so I’m trying to get the basics right here.

A, install,

First, mongodb installation, you can use the terminal directly download installation

Sudo fastdl.mongodb.org/osx/mongodb curl – O…

Decompress sudo tar -zxvf mongodb-osx-ssl-x86_64-4.0.9. TGZ

You can also use Homebrew to install, or you can download the installation package TGZ from the official website.

Modify environment variables

For easy use, open the terminal, type open-e. bash_profile, and add it to the open file

export PATH=${PATH}:/usr/local/MongoDB/bin

MogoDB is the name of the mongodb folder, which can be set at will

Save the configuration with Command+S, edit the.bash_profile window, and then enter “source.bash_profile” in terminal for the configuration to take effect. Type “Mongod-version” and press Enter. If you see the version number, MongoDB has been successfully installed on your Mac.

3. Start mongodb

Mongob startup needs to build a data folder and then create a DB folder.

Error 1: Data /db cannot be found

1, create a database directory /data/db:

sudo mkdir -p /data/db

This is the method in the beginner tutorial, but after the upgrade to 10.15, the system will not be able to create folders in the root directory of the hard drive, so this method is read-only folder, you will run mongod error, can not find /data/db.

Mongod –dbpath /usr/local/data: mongod –dbpath /usr/local/data: mongod –dbpath /usr/local/data: mongod –dbpath /usr/local/data

2020-06-28T23:04:26.570+0800 I SHARDING [LogicalSessionCacheReap] Marking collection config. Transactions as collection version:

At this time, you only need to open another terminal, enter mongo, you can successfully connect to the terminal console of mongodb, the terminal suspended mongodb can not be closed.

To enable free monitoring, run the following command: db.enableFreeMonitoring()

To permanently disable this reminder, run the following command: db.disableFreeMonitoring()


show db

If you see this “>”, you are connected.

### error 2: Mongod Address already in use

This indicates that the mongodb process has been started. At this time, you can search moGO through the “activity monitor” of the system to find the process, and then forcibly exit the process. Enter mongo in the terminal again to start the mongodb database