1. Start and close MongoDB
sudo service mongod start # start
sudo service mongod stop # close
Start mysql
service mysql restart
hupeng@hupeng-vm:~$ ps aux | grep mongod # View the running status of the daemon mongod
mongodb 18454 9.5 1.5 292152 61952? Ssl 12:27 0:00 /usr/bin/mongod --quiet --config /etc/ mongod.conf hupeng
18475 0.0 0.0 15964 936 pts/4 R+ 12:27 0:00 grep --color=auto mongod
2. Uninstall
1. Close the daemon mongod
sudo service mongod stop
2.卸载安装的软件包
sudo apt-get purge mongodb-org*
3.移除数据库和日志文件(数据库和日志文件的路径取决于/etc/mongod.conf文件中的配置)
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
3. View the configuration file
The path where the configuration file mongod.conf is located:
/etc/mongod.conf
content:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb #数据库存储路径
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true #以追加的方式写入日志
path: /var/log/mongodb/mongod.log #日志文件路径
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 #绑定监听的ip 127.0.0.1只能监听本地的连接,可以改为0.0.0.0
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp: