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使用服务方式安装
'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'日志需要指定具体的文件,比如MongoLog.log 之前没有置顶就报错【服务没有及时响应或控制请求】
安装、删除服务指令
mongod --install
mongod --service
mongod --remove
mongod --reinstall
或者
C:\mongodb\bin\mongod.exe --remove
启动服务
net start Mongodb停止服务
net stop Mongodb测试简单JavaScript语句
> 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的区别
Create and Alter
The following table presents the various SQL statements related totable-level actions and the corresponding MongoDB statements.
SQL Schema Statements | MongoDB Schema Statements | Reference |
---|---|---|
CREATE TABLE users ( id MEDIUMINT NOT NULL AUTO_INCREMENT, user_id Varchar(30), age Number, status char(1), PRIMARY KEY (id) ) |
Implicitly created on first insert() operation. The primary key_idis automatically added if_id field is not specified. db.users.insert( { user_id: "abc123", age: 55, status: "A" } ) However, you can also explicitly create a collection: db.createCollection("users") |
Seeinsert() anddb.createCollection()for more information. |
ALTER TABLE users ADD join_date DATETIME |
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. db.users.update( { }, { $set: { join_date: new Date() } }, { multi: true } ) |
See the Data Modeling Concepts, update(), and$set for moreinformation on changing the structure of documents in acollection. |
ALTER TABLE users DROP COLUMN join_date |
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. db.users.update( { }, { $unset: { join_date: "" } }, { multi: true } ) |
See Data Modeling Concepts, update(), and$unset for more information on changing the structure ofdocuments in a collection. |
CREATE INDEX idx_user_id_asc ON users(user_id) |
db.users.ensureIndex( { user_id: 1 } ) |
See ensureIndex()andindexes for more information. |
CREATE INDEX idx_user_id_asc_age_desc ON users(user_id, age DESC) |
db.users.ensureIndex( { user_id: 1, age: -1 } ) |
See ensureIndex()andindexes for more information. |
DROP TABLE users |
db.users.drop() |
See drop() formore information. |
Insert
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 |
---|---|---|
INSERT INTO users(user_id, age, status) VALUES ("bcd001", 45, "A") |
db.users.insert( { user_id: "bcd001", age: 45, status: "A" } ) |
See insert() for more information. |
Select
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 |
---|---|---|
SELECT * FROM users |
db.users.find() |
See find()for more information. |
SELECT id, user_id, status FROM users |
db.users.find( { }, { user_id: 1, status: 1 } ) |
See find()for more information. |
SELECT user_id, status FROM users |
db.users.find( { }, { user_id: 1, status: 1, _id: 0 } ) |
See find()for more information. |
SELECT * FROM users WHERE status = "A" |
db.users.find( { status: "A" } ) |
See find()for more information. |
SELECT user_id, status FROM users WHERE status = "A" |
db.users.find( { status: "A" }, { user_id: 1, status: 1, _id: 0 } ) |
See find()for more information. |
SELECT * FROM users WHERE status != "A" |
db.users.find( { status: { $ne: "A" } } ) |
See find()and$ne for more information. |
SELECT * FROM users WHERE status = "A" AND age = 50 |
db.users.find( { status: "A", age: 50 } ) |
See find()and$and for more information. |
SELECT * FROM users WHERE status = "A" OR age = 50 |
db.users.find( { $or: [ { status: "A" } , { age: 50 } ] } ) |
See find()and$or for more information. |
SELECT * FROM users WHERE age > 25 |
db.users.find( { age: { $gt: 25 } } ) |
See find()and$gt for more information. |
SELECT * FROM users WHERE age < 25 |
db.users.find( { age: { $lt: 25 } } ) |
See find()and$lt for more information. |
SELECT * FROM users WHERE age > 25 AND age <= 50 |
db.users.find( { age: { $gt: 25, $lte: 50 } } ) |
See find(),$gt, and $lte formore information. |
SELECT * FROM users WHERE user_id like "%bc%" |
db.users.find( { user_id: /bc/ } ) |
See find()and$regex for more information. |
SELECT * FROM users WHERE user_id like "bc%" |
db.users.find( { user_id: /^bc/ } ) |
See find()and$regex for more information. |
SELECT * FROM users WHERE status = "A" ORDER BY user_id ASC |
db.users.find( { status: "A" } ).sort( { user_id: 1 } ) |
See find()andsort()for more information. |
SELECT * FROM users WHERE status = "A" ORDER BY user_id DESC |
db.users.find( { status: "A" } ).sort( { user_id: -1 } ) |
See find()andsort()for more information. |
SELECT COUNT(*) FROM users |
db.users.count() or db.users.find().count() |
See find()andcount() formore information. |
SELECT COUNT(user_id) FROM users |
db.users.count( { user_id: { $exists: true } } ) or db.users.find( { user_id: { $exists: true } } ).count() |
See find(),count(), and$exists for more information. |
SELECT COUNT(*) FROM users WHERE age > 30 |
db.users.count( { age: { $gt: 30 } } ) or db.users.find( { age: { $gt: 30 } } ).count() |
See find(),count(), and$gt for more information. |
SELECT DISTINCT(status) FROM users |
db.users.distinct( "status" ) |
See find()anddistinct()for more information. |
SELECT * FROM users LIMIT 1 |
db.users.findOne() or db.users.find().limit(1) |
See find(),findOne(),andlimit()for more information. |
SELECT * FROM users LIMIT 5 SKIP 10 |
db.users.find().limit(5).skip(10) |
See find(),limit(), andskip() formore information. |
EXPLAIN SELECT * FROM users WHERE status = "A" |
db.users.find( { status: "A" } ).explain() |
See find()andexplain()for more information. |
Update Records
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 |
---|---|---|
UPDATE users SET status = "C" WHERE age > 25 |
db.users.update( { age: { $gt: 25 } }, { $set: { status: "C" } }, { multi: true } ) |
See update(),$gt, and $set for moreinformation. |
UPDATE users SET age = age + 3 WHERE status = "A" |
db.users.update( { status: "A" } , { $inc: { age: 3 } }, { multi: true } ) |
See update(),$inc, and $set for moreinformation. |
Delete Records
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 |
---|---|---|
DELETE FROM users WHERE status = "D" |
db.users.remove( { status: "D" } ) |
See remove()for more information. |
DELETE FROM users |
db.users.remove( ) |
See remove()for more information. |

산성 속성에는 원자력, 일관성, 분리 및 내구성이 포함되며 데이터베이스 설계의 초석입니다. 1. 원자력은 거래가 완전히 성공적이거나 완전히 실패하도록합니다. 2. 일관성은 거래 전후에 데이터베이스가 일관성을 유지하도록합니다. 3. 격리는 거래가 서로를 방해하지 않도록합니다. 4. 지속성은 거래 제출 후 데이터가 영구적으로 저장되도록합니다.

MySQL은 데이터베이스 관리 시스템 (DBMS) 일뿐 만 아니라 프로그래밍 언어와 밀접한 관련이 있습니다. 1) DBMS로서 MySQL은 데이터를 저장, 구성 및 검색하는 데 사용되며 인덱스 최적화는 쿼리 성능을 향상시킬 수 있습니다. 2) SQL과 같은 ORM 도구를 사용하여 Python에 내장 된 SQL과 프로그래밍 언어를 결합하면 작업을 단순화 할 수 있습니다. 3) 성능 최적화에는 인덱싱, 쿼리, 캐싱, 라이브러리 및 테이블 부서 및 거래 관리가 포함됩니다.

MySQL은 SQL 명령을 사용하여 데이터를 관리합니다. 1. 기본 명령에는 선택, 삽입, 업데이트 및 삭제가 포함됩니다. 2. 고급 사용에는 조인, 하위 쿼리 및 집계 함수가 포함됩니다. 3. 일반적인 오류에는 구문, 논리 및 성능 문제가 포함됩니다. 4. 최적화 팁에는 인덱스 사용, 선택*을 피하고 한계 사용이 포함됩니다.

MySQL은 데이터 저장 및 관리에 적합한 효율적인 관계형 데이터베이스 관리 시스템입니다. 장점에는 고성능 쿼리, 유연한 트랜잭션 처리 및 풍부한 데이터 유형이 포함됩니다. 실제 애플리케이션에서 MySQL은 종종 전자 상거래 플랫폼, 소셜 네트워크 및 컨텐츠 관리 시스템에서 사용되지만 성능 최적화, 데이터 보안 및 확장성에주의를 기울여야합니다.

SQL과 MySQL의 관계는 표준 언어와 특정 구현의 관계입니다. 1.SQL은 관계형 데이터베이스를 관리하고 운영하는 데 사용되는 표준 언어로, 데이터 추가, 삭제, 수정 및 쿼리를 허용합니다. 2.MySQL은 SQL을 운영 언어로 사용하고 효율적인 데이터 저장 및 관리를 제공하는 특정 데이터베이스 관리 시스템입니다.

InnoDB는 Redologs 및 Undologs를 사용하여 데이터 일관성과 신뢰성을 보장합니다. 1. Redologs는 사고 복구 및 거래 지속성을 보장하기 위해 데이터 페이지 수정을 기록합니다. 2. 결점은 원래 데이터 값을 기록하고 트랜잭션 롤백 및 MVCC를 지원합니다.

설명 명령에 대한 주요 메트릭에는 유형, 키, 행 및 추가가 포함됩니다. 1) 유형은 쿼리의 액세스 유형을 반영합니다. 값이 높을수록 Const와 같은 효율이 높아집니다. 2) 키는 사용 된 인덱스를 표시하고 NULL은 인덱스가 없음을 나타냅니다. 3) 행은 스캔 한 행의 수를 추정하여 쿼리 성능에 영향을 미칩니다. 4) Extra는 최적화해야한다는 Filesort 프롬프트 사용과 같은 추가 정보를 제공합니다.

Temporary를 사용하면 MySQL 쿼리에 임시 테이블을 생성해야 할 필요성이 있으며, 이는 별개의, 그룹 비 또는 비 인덱스 열을 사용하여 순서대로 발견됩니다. 인덱스 발생을 피하고 쿼리를 다시 작성하고 쿼리 성능을 향상시킬 수 있습니다. 구체적으로, 설명 출력에 사용되는 경우, MySQL은 쿼리를 처리하기 위해 임시 테이블을 만들어야 함을 의미합니다. 이것은 일반적으로 다음과 같은 경우에 발생합니다. 1) 별개 또는 그룹을 사용할 때 중복 제거 또는 그룹화; 2) OrderBy가 비 인덱스 열이 포함되어있을 때 정렬하십시오. 3) 복잡한 하위 쿼리 또는 조인 작업을 사용하십시오. 최적화 방법은 다음과 같습니다. 1) Orderby 및 GroupB


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기
