export
Go to the installation directory of mongodb\Server\3.6\bin
mongodump --host 192.168.1.2:27017 -d dbname -uuername mongo -ppasswd 123456 -o /dump
- --host : configure the service access address of mongodb
- -d: Specifies the database. Optional parameter, export all DBs without this parameter
- -uuername: Specify the username to connect to mongodb
- -ppasswd: Specify the password to connect to mongodb
- -o: specify the output directory
mongodb start command
$ mongod -f mongod.conf --serviceName MongoDB --install
$ net start MongoDB
mongod.conf :
systemLog:
destination: file
path: 'F:\Mongodb\Server\logs\mongod.log'
logAppend: true
storage:
journal:
enabled: true
dbPath: 'F:\Mongodb\Server\data'
net:
bindIp: 0.0.0.0
port: 27017
setParameter:
enableLocalhostAuthBypass: false
recover
mongorestore -h hostname:port -d dbname <path>
some important parameters
- -h[:port] specifies the server address where MongoDB is located, the default is localhost
- -d database to restore
- –drop When restoring, delete the current database first, and then restore the backup, operate with caution
- Set the location of the backup data, which conflicts with the parameters below
- –dir specifies the backup directory, which conflicts with the above parameters