You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

cd /usr/local
rz -be 选择mongodb-linux-x86_64-rhel80-4.2.24.tgz
tar zxvf mongodb-linux-x86_64-rhel80-4.2.24.tgz -C /usr/local/
mv mongodb-linux-x86_64-rhel80-4.2.24 mongodb
rm -rf mongodb-linux-x86_64-rhel80-4.2.24.tgz
#添加环境变量
vi /etc/profile
export PATH=/usr/local/mongodb/bin:$PATH
#生效
source /etc/profile
# 创建文件
cd /usr/local/mongodb
touch mongodb.conf
mkdir db
mkdir log
cd log
touch mongodb.log
#设置文件夹权限
cd /usr/local/mongodb
chmod 777 db
chmod 777 log
# 启动MongoDB
/usr/local/mongodb/bin/mongod --dbpath /usr/local/mongodb/db --bind_ip 0.0.0.0 --port 27017 --fork --journal --logpath /usr/local/mongodb/log/mongod.log --logappend --noauth --directoryperdb
yum install net-tools -y
netstat -lanp | grep "27017"
mongo #进入MongoDB控制台
show dbs #查看默认数据库
use admin #切换到admin数据库
exit #退出MongoDB控制台
# 关闭数据库
/usr/local/mongodb/bin/mongod --shutdown --dbpath /usr/local/mongodb/db
# 常用维护命令
https://blog.csdn.net/Waldocsdn/article/details/130155631
#mongodb如何设置用户名和密码
https://www.cnblogs.com/knighterrant/p/17823322.html
# 备份数据库
https://mp.weixin.qq.com/s?__biz=MjM5NTcxMTE2Nw==&mid=2653126118&idx=2&sn=d7c3fa8bc119856dae3d66de09067ab8&chksm=bd238c368a5405209c9b9e5409afe31a39c3774b09312164822933734639eefd0289e74e5a48&scene=27
mongodump