----------------
C:\WINDOWS\system32>mongod --dbpath=D:\developer\mongo\db\ --logpath=D:\developer\mongo\log.txt --install2017-10-13T00:15:51.173+0800 I CONTROL [main] logfile"D:\developer\mongo\log.txt" exists; moved to"D:\developer\mongo\log.txt.2017-10-12T16-15-51".
-------------------
C:\WINDOWS\system32>mongo
MongoDB shellversion v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
Welcome tothe MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2017-10-13T00:17:59.907+0800 I CONTROL [initandlisten]
2017-10-13T00:17:59.908+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled forthe database.
2017-10-13T00:17:59.908+0800 I CONTROL [initandlisten] ** Read andwrite access to data and configuration is unrestricted.
2017-10-13T00:17:59.908+0800 I CONTROL [initandlisten]
>
常用操作
查看当前库名称 db.getName()
创建数据库 use 数据库名
查看数据库状态 db.stats()
简单计算
使用db.help()查看帮助信息
> db.getName()
test
> use mark
switched to db mark
> db.getName()
mark
>
> db.stats()
{
"db" : "mark",
"collections" : 0,
"views" : 0,
"objects" : 0,
"avgObjSize" : 0,
"dataSize" : 0,
"storageSize" : 0,
"numExtents" : 0,
"indexes" : 0,
"indexSize" : 0,
"fileSize" : 0,
"ok" : 1
}
>
> x=100100
> y=200200
> x+y300
> x-y
-100
> x*y20000
> x/y0.5
>