mongodb简单操作

发布时间:2020-06-12编辑:郑雅娟阅读(110)

    1. ./mongod -f /opt/mongodb/bin/mongodb.conf --repair       修复启动

    2. ./mongod -config /opt/mongodb/bin/mongodb.conf            启动

    3.  netstat -anpt | grep mongod                                        查看进程

    4. ./mongo 127.0.0.1:8001                                                    连接数据库

    5. db.createUser({user:'bus',pwd:'bus123$',roles:[{role:'dbOwner', db:'bus'}]});

    6. db.createUser(

    7.   {

    8.     user: "bus",

    9.     pwd: "bus123$",

    10.     roles: [ { role: "dbOwner", db: "bus" } ]

    11.   }

    12. )