阿里云服务器安装mongodb的方法
1.下载mongodb
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.9.tgz
2.解压
tar zxvf mongodb-linux-x86_64-3.2.9.tgz
3.创建数据文件夹和日志文件等
mkdir -p /usr/local/mongodb/data touch /usr/local/mongodb/mongod.log touch /usr/local/mongodb/mongodb.conf
4.启动
进入mongo的bin目录下执行
(1)参数启动
./mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/mongod.log --logappend --port=27017 --fork
(2) 配置文件启动
./mongod --config /usr/local/mongodb/mongodb.conf
配置文件如下
dbpath=/usr/local/mongodb/data logpath=/usr/local/mongodb/mongod.log logappend = true port = 27017 fork = true auth = true
5.创建用户(创建完成后需要在阿里云控制台配置防火墙才能连接)
db.createUser({'user':"用户名","pwd":"密码",roles:[{'role':"角色权限(dbAdmin)",db:"admin"}]})
总结
相关推荐
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