本文共 1842 字,大约阅读时间需要 6 分钟。
现在已有很多大公司使用了NoSQL:Google/Facebook/Adobe
数据库类型 | 存储类型 | 部分代表 | 特点 |
---|---|---|---|
NoSQL非关系型数据库 | 文档存储 | MongoDB | 文档存储一般用类似json的格式存储,存储的内容是文档型的。这样也就有机会对某些字段建立索引,实现关系数据库的某些功能。 |
key-value存储 | Redis | 可以通过key快速查询到其value。 |
SQL术语 | MongoDB术语 | 解释/说明 |
---|---|---|
database | database | 数据库 |
table | collection | 数据库表/集合 |
row | document | 数据记录行/文档 |
column | field | 数据字段/域 |
index | index | 索引 |
primary key | primary key | 主键,MongoDB自动将_id字段设置为主键 |
C:\mongodb\bin\mongod --dbpath c:\data\db如果执行成功,会输出如下信息:2015-09-25T15:54:09.212+0800 I CONTROL Hotfix KB2731284 or later update is notinstalled, will zero-out data files2015-09-25T15:54:09.229+0800 I JOURNAL [initandlisten] journal dir=c:\data\db\journal2015-09-25T15:54:09.237+0800 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed2015-09-25T15:54:09.290+0800 I JOURNAL [durability] Durability thread started2015-09-25T15:54:09.294+0800 I CONTROL [initandlisten] MongoDB starting : pid=2488 port=27017 dbpath=c:\data\db 64-bit host=WIN-1VONBJOCE882015-09-25T15:54:09.296+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R22015-09-25T15:54:09.298+0800 I CONTROL [initandlisten] db version v3.0.6……
MongoDB连接URI:
mongodb://[username:password@]host1[:port1][,host2[:port2],…[,hostN[:portN]]][/[database][?options]]
mongodb:// 这是固定的格式,必须要指定。
username:password@ 可选项,如果设置,在连接数据库服务器之后,驱动都会尝试登录这个数据库
host1 必须的指定至少一个host, host1 是这个URI唯一要填写的。它指定了要连接服务器的地址。如果要连接复制集,请指定多个主机地址。
portX 可选的指定端口,如果不填,默认为27017
/database 如果指定username:password@,连接并验证登录指定数据库。若不指定,默认打开 test 数据库。
?options 是连接选项。如果不使用/database,则前面需要加上/。所有连接选项都是键值对name=value,键值对之间通过&或;(分号)隔开
转载地址:http://bzqgn.baihongyu.com/