1.啓動和關閉MongoDB
sudo service mongod start # 啓動
sudo service mongod stop # 關閉
啓動 mysql
service mysql restart
hupeng@hupeng-vm:~$ ps aux | grep mongod # 查看守護進程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.卸載
1. 關閉守護進程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.查看配置文件
配置文件mongod.conf所在路徑:
/etc/mongod.conf
內容:
# 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: