I met a problem while I was learning MongoDB. Here are my steps eliciting the problem:
-
I start MongoDB service:
mongod
. -
In my terminal, at the MongoDB service window, I carelessly close it without using
ctrl + c
to kill the service process. -
Now, I cannot manipulate MongoDB service AT ALL…
Solution
There might be several different ways to solve the problem in different systems. Mine is MacOS, so here is my solution:
-
Open a new window of terminal, type
mongo
, to enter MongoDB, as the process is still working, so I’m able to login. -
type
use admin
to get the root permission. -
type
db.shutdownServer()
.
Now the service has been closed successfully. I can simply type mongod
to start it again, and manipulate by using the normal window. Next time, I will be carefull when trying to close a terminal window. Attatching this solution in case the same condition happens in future.