2.mongodb的一些操作

66 阅读1分钟

常见操作

1.关闭数据库服务

./mongosh

use admin

db.shutdownServer();
  1. 启动数据库服务
sudo ./mongod -f /usr/local/mongodb/mongodb.conf

/usr/local/mongodb/mongodb.conf 是启动的配置文件

3.恢复数据库

./mongorestore -h localhost:27017 -d mysite --dir /Users/hongliangchang/Desktop/mysiteDB

数据库服务一定要先关闭才能进行其他恢复操作或者其他操作,如果没有关闭启动的话会报下面的错误

about to fork child process, waiting until server is ready for connections.
forked process: 5978
ERROR: child process failed, exited with 1
To see additional information in this output, start without the "--fork" option