MongoDB 创建新用户并授权

进入mongo数据库

登录

mongo localhost:27017/admin -u pfnieadmin -p 123456

mongodb查看版本
db.version()

查看所有数据库

show dbs
admin 0.000GB
local 0.000GB
yapi 0.224GB

切换数据库

use yapi
switched to db yapi

查看当前数据库

db
yapi

查看当前数据库下的所有表(或叫collection)

show collections
adv_mock
adv_mock_case
avatar
follow
group
identitycounters
interface
interface_auto_sync
interface_case
interface_cat
interface_col
log
project
statis_mock
storage
token
user
wiki

查看帮助命令

help
db.help() help on db methods
db.mycoll.help() help on collection methods
sh.help() sharding helpers
rs.help() replica set helpers
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce

    show dbs                     show database names
    show collections             show collections in current database
    show users                   show users in current database
    show profile                 show most recent system.profile entries with time >= 1ms
    show logs                    show the accessible logger names
    show log [name]              prints out the last segment of log in memory, 'global' is default
    use <db_name>                set current database
    db.foo.find()                list objects in collection foo
    db.foo.find( { a : 1 } )     list objects in foo where a == 1
    it                           result of the last line evaluated; use to further iterate
    DBQuery.shellBatchSize = x   set default number of items to display on shell
    exit                         quit the mongo shell

查看当前库支持哪些方法

db.help()
DB methods:
db.adminCommand(nameOrDocument) - switches to ‘admin’ db, and runs command [ just calls db

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值