时间:2021-07-01 10:21:17 帮助过:3人阅读
5,执行下面的命令启动mongodb
[root@localhost local]# sudo service mongod start
6,关闭执行下面的命令(官方文档中提供的关闭命令sudo service mongod stop 执行后,进程一直存在导致端口占用)
mongod --shutdown --dbpath /var/lib/mongo
备注:1,出现下面的原因一般是修改了数据文件目录和日志文件目录,又没有将相应的权限授权给运行mongodb的用户。解决方法:授权即可
mongod.service - SYSV: Mongo is a scalable, document-oriented database. Loaded: loaded (/etc/rc.d/init.d/mongod) Active: failed (Result: exit-code) since 五 2015-05-08 13:54:05 CST; 2min 13s ago Process: 4493 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)
备注:3,默认mongodb是不对用户进行权限,授权需要在/etc/mongod.conf设置,在mongodb shell中添加用户
bye [root@localhost local]# mongo 192.168.xx.xx MongoDB shell version: 3.0.2 connecting to: 192.168.xx.xx/test > switched to db admin > db.createUser( { user: "root", pwd: "joeyon1985", roles: [ "readWrite" ] } ) Successfully added user: { "user" : "root", "roles" : [ "readWrite" ] } > db.createUser( { user: "root", pwd: "joeyon1985", roles: [ "readWrite" ] } )
add by joeyon1985
redhat下mongodb的安装
标签: