1、前台开启的进程可直接Ctrl+c终止服务
2、kill进程
# ps -ef |grep mongo |grep -v grep
root 10832 1 2 11:39 ? 00:00:00 mongod -f mongodb.cnf --fork
# kill -9 10832
说明:--fork为mongodb后台启动服务的参数,详见:http://blog.csdn.net/u010587433/article/details/47803751
3、使用db.shutdownServer()函数(必须切换至admin库)
> db
cric
> db.shutdownServer()
shutdown command only works with the admin database; try 'use admin'
> use admin
switched to db admin
> db.shutdownServer()
2015-08-21T11:35:07.831+0800 I NETWORK DBClientCursor::init call() failed
server should be down...
2015-08-21T11:35:07.875+0800 I NETWORK trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2015-08-21T11:35:07.876+0800 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-08-21T11:35:07.876+0800 I NETWORK reconnect 127.0.0.1:27017 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed