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: