Connect failed mongo db on mac osx

I am trying to learn mongo db on my mac. I installed mondgo db using homebrew and it appeared successfully. I created dir /data/db . when I type mongo into the terminal, I get:

 Error: couldn't connect to server [a bunch of numbers] at src/mongo/shell/mongo.js:145 exception:connect failed 

I looked at the following answer on SO: Installing and running MongoDB on OSX

the control answer says: 1) Launch the terminal for your mongo server 2) Go to the mongo / bin directory

What does starting a terminal mean for your server? Does this just mean opening a new terminal window?

Where can I find the mongo / bin directory?

Any other suggestions for enabling and running mondoDB would be appreciated.

+6
source share
3 answers

you should read the documentation here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ Follow the instructions.

In this case, [group of numbers] is the host name / ip and the port number to which binary mongo tried to connect. It tells you that there is no binary mongod listening for the host name and port that mongo is trying to connect mongo .

You will need to start mongod before you can connect to it using the mongo shell. The above documentation describes this further.

If you use homebrew mongodb binaries will be automatically placed in your path, which means that you will not need to write cd to another directory, for example mongo / bin.

Good luck.

+10
source

You might be the first to run mongodb. Based on the documentation, you have to follow a few steps, and then you are ready to go.

First create the main db directory:

 sudo mkdir -p /data/db 

Make sure you have read and write permissions in this directory:

 sudo chown `id -u` /data/db 

And to listen on the default port, run:

 mongod 

Finally, keep in mind that after running the "mongod" command, do not close the console tab. Open a new tab (Cmd + T) and run other commands in a new window. To close a mongod session, simply press Ctrl + C on the previous tab.

+6
source

These steps worked fine for me on a Mac, you can take a snapshot, first install brew and put these lines in line by line:

 brew update brew install mongodb brew install mongodb --with-openssl brew install mongodb --devel sudo mkdir -p /data/db sudo chown -R [your username] /data/db (Replace with your username with what you can get by typing whoami in the terminal) mongod 

Launch an application, for example localhost: 8000

0
source

Source: https://habr.com/ru/post/959341/


All Articles