window server 2012上安装mongo4.0
2021-03-28 11:25
mongod 启动数据库
mongod --dbpath “” 启动数据库时指定数据目录,不指定时数据目录默认为安装盘符:\data\db
后台启动
start /b mongod
启动示例
md "D:\data\MongoDB\Server\4.0\data\db"
mongod --dbpath "D:\data\MongoDB\Server\4.0\data\db"
连接数据库
PS D:\Users\Administrator> mongo
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.0
Server has startup warnings:
2018-07-18T23:36:39.472+0800 I CONTROL [initandlisten]
2018-07-18T23:36:39.472+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-18T23:36:39.472+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-07-18T23:36:39.472+0800 I CONTROL [initandlisten]
> db
test
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
创建数据库
> use vodb
switched to db vodb
> db
vodb
mongodb中的数据库至少要插入一个文档才能显示出来
> db
vodb
> db.chkrecord.insert({
... _id: 100,
... chktime: ‘2018-07-19 0:10:15‘,
... chk_key: ‘75‘,
... chkname: ‘system tbs used pct‘,
... ipaddress: ‘192.168.2.116‘,
... dbname: ‘test‘,
... })
WriteResult({ "nInserted" : 1 })
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
vodb 0.000GB
> db.chkrecord.find().pretty()
{
"_id" : 100,
"chktime" : "2018-07-19 0:10:15",
"chk_key" : "75",
"chkname" : "system tbs used pct",
"ipaddress" : "192.168.2.116",
"dbname" : "test"
}
使用刚才的连接工具MongoDB Compass Community进行连接,不需要修改信息,按默认的连接即可
上一篇:Redis多API开发实践
下一篇:C# 判断字符串是否左包含
文章标题:window server 2012上安装mongo4.0
文章链接:http://soscw.com/essay/69020.html