进入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