Reputation: 6344
I'm on OS/X Macbook and recently installed mongodb to try my hands on it. I installed it using shell commands. I scrapped some data and passed into it and when I tried looking for it, the connection was getting failed. On googling the root cause, I found there was some mongodb.lock
file, and I removed it using bash command.
Now, I'm trying to restart using the following command
sudo service mongodb restart
However, it is saying
sudo: service: command not found
in addition, if I start mongodb by navigating to folder and then using the command ./bin/mongo
, it displays the following error:
MongoDB shell version: 3.0.7 connecting to: test 2015-11-08T14:47:56.965+0800 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused 2015-11-08T14:47:56.967+0800 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at connect (src/mongo/shell/mongo.js:179:14) at (connect):1:6 at src/mongo/shell/mongo.js:179 exception: connect failed
can someone please help how to resolve it.
Upvotes: 0
Views: 544
Reputation: 20703
service
command on OS X. You need to manage MongoDB yourself by starting it with the mongod
command.An Alternative is to install MongoDB via MacPorts. After you successfully installed MacPorts, you simply install MongoDB with
sudo port install mongodb
You can start MongoDB quite easily then with
sudo port load mongodb
and stop it with
sudo port unload mongodb
mongo
is the client. You haven't had the server running, so it is only natural that you can not connect to the server.
Some side note: OS X is not very close to Linux. OS X is based on a flavor of BSD-UNIX, which in turn is based on Research UNIX. Linux started as a free implementation of Minix, based on GNU utilities. So assuming that you'd have Linux tools available on the OS X command line is pretty dangerous. Often, the tools (if present) even share the name, but are different implementations of the same functionality with some differences in usage. So, get it in your head: With OS X, you do not use the hipster version of Linux – you use BSD on steroids. Hence, I will remove the "linux" tag and add the OS X tag.
Upvotes: 1