DEV Community

tingshuai
tingshuai

Posted on

mongodb常见操作

  • 进入mongodb容器: docker exec -it mongodb bash

  • 连接数据库:
    进入bin文件夹然后执行mongosh db_name -u ... -p ...

  • 创建root用户:

db.createUser({ 'user' : 'root', 'pwd' : '123123', 'roles':[ {role:'root',db:'admin'}  ]})
Enter fullscreen mode Exit fullscreen mode

Top comments (0)