时间:2021-07-01 10:21:17 帮助过:46人阅读
mongodb安装笔记 --下面大部分都是参考网上资料,仅仅作为笔记使用 参考链接 Mongodb官网安装 Mongodb官网对比 相关文档 我的mongodb安装在[d:\Java\mongodb] 所以需要根目录手动创建文件夹【e:\data\db】 mongodb使用服务方式安装 D:\Java\mongodb\bin\mong
mongodb安装笔记
--下面大部分都是参考网上资料,仅仅作为笔记使用
参考链接
Mongodb官网安装
Mongodb官网对比
相关文档
我的mongodb安装在[d:\Java\mongodb]
所以需要根目录手动创建文件夹【e:\data\db】
mongodb使用服务方式安装
日志需要指定具体的文件,比如MongoLog.log 之前没有置顶就报错【服务没有及时响应或控制请求】
- 'D:\Java\mongodb\bin\mongod.exe --bind_ip 127.0.0.1 --logpath d:\\Java\\mongodb
- \\logs\\MongoLog.log --logappend --dbpath d:\\data --directoryperdb --service'
- Fri Jan 10 09:17:45.050 Service can be started from the command line with 'net s
- tart MongoDB'
安装、删除服务指令
mongod --install
mongod --service
mongod --remove
mongod --reinstall
或者
- C:\mongodb\bin\mongod.exe --remove
启动服务
停止服务
- net start Mongodb
测试简单JavaScript语句
- net stop Mongodb
- > 3+3
- 6
- > db
- test
- > // the first write will create the db:
- > db.foo.insert( { a : 1 } )
- > db.foo.find()
- { _id : ..., a : 1 }
- mongo.exe的详细的用法可以参考mongo.exe --help
下面从官网摘抄下来的普通sql跟MongoDB的区别
The following table presents the various SQL statements related totable-level actions and the corresponding MongoDB statements.
SQL Schema Statements | MongoDB Schema Statements | Reference |
---|---|---|
|
Implicitly created on first insert() operation. The primary key_idis automatically added if_id field is not specified.
However, you can also explicitly create a collection:
|
Seeinsert() anddb.createCollection()for more information. |
|
Collections do not describe or enforce the structure of itsdocuments; i.e. there is no structural alteration at thecollection level. However, at the document level, update() operations can add fields to existingdocuments using the$set operator.
|
See the Data Modeling Concepts, update(), and$set for moreinformation on changing the structure of documents in acollection. |
|
Collections do not describe or enforce the structure of itsdocuments; i.e. there is no structural alteration at the collectionlevel. However, at the document level, update() operations can remove fields fromdocuments using the$unset operator.
|
See Data Modeling Concepts, update(), and$unset for more information on changing the structure ofdocuments in a collection. |
|
|
See ensureIndex()andindexes for more information. |
|
|
See ensureIndex()andindexes for more information. |
|
|
See drop() formore information. |
The following table presents the various SQL statements related toinserting records into tables and the corresponding MongoDB statements.
SQL INSERT Statements | MongoDB insert() Statements | Reference |
---|---|---|
|
|
See insert() for more information. |
The following table presents the various SQL statements related toreading records from tables and the corresponding MongoDB statements.
SQL SELECT Statements | MongoDB find() Statements | Reference |
---|---|---|
|
|
See find()for more information. |
|
|
See find()for more information. |
|
|
See find()for more information. |
|
|
See find()for more information. |
|
|
See find()for more information. |
|
|
See find()and$ne for more information. |
|
|
See find()and$and for more information. |
|
|
See find()and$or for more information. |
|
|
See find()and$gt for more information. |
|
|
See find()and$lt for more information. |
|
|
See find(),$gt, and $lte formore information. |
|
|
See find()and$regex for more information. |
|
|
See find()and$regex for more information. |
|
|
See find()andsort()for more information. |
|
|
See find()andsort()for more information. |
|
or
|
See find()andcount() formore information. |
|
or
|
See find(),count(), and$exists for more information. |
|
or
|
See find(),count(), and$gt for more information. |
|
|
See find()anddistinct()for more information. |
|
or
|
See find(),findOne(),andlimit()for more information. |
|
|
See find(),limit(), andskip() formore information. |
|
|
See find()andexplain()for more information. |
The following table presents the various SQL statements related toupdating existing records in tables and the corresponding MongoDBstatements.
SQL Update Statements | MongoDB update() Statements | Reference |
---|---|---|
|
|
See update(),$gt, and $set for moreinformation. |
|
|
See update(),$inc, and $set for moreinformation. |
The following table presents the various SQL statements related todeleting records from tables and the corresponding MongoDB statements.
SQL Delete Statements | MongoDB remove() Statements | Reference |
---|---|---|
|
|
See remove()for more information. |
|
|
See remove()for more information. |