CentOS7配置MongoDB
[官网]下载mongodb-linux-x86_64-rhel62-3.4.3.tgz
通过FTP(WinSCP,FileZilla等)工具上传到“/apps”目录
使用解压命令解压到当前目录
tar -zvxf mongodb-linux-x86_64-rhel62-3.4.3.tgz
开启27017端口
firewall-cmd --zone=public --add-port=27017/tcp --permanent (--permanent永久生效,没有此参数重启后失效) #重新载入 firewall-cmd --reload
创建data文件夹用于存放数据,创建logs文件用于存放日志
cd mongodb-linux-x86_64-rhel62-3.4.3 mkdir data touch logs
启动MongoDB
/apps/mongodb-linux-x86_64-rhel62-3.4.3/bin/mongod -dbpath=/apps/mongodb-linux-x86_64-rhel62-3.4.3/data -logpath=/apps/mongodb-linux-x86_64-rhel62-3.4.3/logs --fork --auth
创建超级用户
cd /apps/mongodb-linux-x86_64-rhel62-3.4.3/bin ./mongo use admin db.createUser( ... { ... user: "admin", ... pwd: "admin", ... roles: [ { role: "root", db: "admin" } ] ... } ... )
登陆admin用户
db.auth(‘admin‘,‘admin‘);
创建登陆用户
use test db.createUser( ... { ... user: "test", ... pwd: "test", ... roles: [ { role: "readWrite", db: "test" } ] ... } ... )
设置开机启动
#设置开机启动 #修改/etc/下的rc.local添加如下命令 /apps/mongodb-linux-x86_64-rhel62-3.4.3/bin/mongod -dbpath=/apps/mongodb-linux-x86_64-rhel62-3.4.3/data -logpath=/apps/mongodb-linux-x86_64-rhel62-3.4.3/logs --fork --auth
相关推荐
lbyd0 2020-11-17
BigYellow 2020-11-16
sushuanglei 2020-11-12
我心似明月 2020-11-09
zhushenghan 2020-11-09
sunnnyduan 2020-10-16
不要皱眉 2020-10-14
xiaohai 2020-09-29
songxiugongwang 2020-09-22
萌亖 2020-09-17
LuckyLXG 2020-09-08
sdmzhu 2020-09-01
mkhhxxttxs 2020-09-16
xiaohai 2020-09-16
newcome 2020-09-09
jaylong 2020-08-19
大秦铁骑 2020-08-19
thatway 2020-08-19