mongoDB在linux上的使用

1.启动mongodb

sudo service mongod start

2.查看mongodb的运行状态

sudo service mongod status

3.关闭防火墙

systemctl stop firewalld

4.查看防火墙状态

systemctl status firewalld

5.进入mongodb命令行

mongo

6.创建mongodb用户

use admin
db.createUser({user:"admin",pwd:"admin",roles:["root"]})
db.auth("admin","admin")

7.创建tb_autopick数据库及其用户admin

use tb_autopick
db.createUser({user: "admin", pwd: "123456", roles: [{ role: "dbOwner", db: "tb_autopick" }]})

8.查找mongod.conf文件

whereis mongod.conf
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章