webplus / blog

前端开发日志
63 stars 6 forks source link

MongoDB常用操作 #26

Open webplus opened 7 years ago

webplus commented 7 years ago

1.查询是否已启动 ps -ef|grep mongodb

2.后台启动 mongod --dbpath ./data/mongo --logpath ./log/mongodb/mongod.log --fork --logappend --port 27017 --auth

3.客户端 mongo

4.非正常退出导致的启动 报错: about to fork child process, waiting until server is ready for connections. ERROR: child process failed, exited with error number 100 修复:

rm -rf /data/mongodb/mongo.lock --linux

del /data/mongodb/mongo.lock --windows

执行:

mongod --repair --dbpath=./data/mongo

正确关闭mongod 的方法:进入mongo shell:

use admin
db.shutdownServer()