Table of Contents
Create and Alter
Insert
Select
Update Records
Delete Records
Home Database Mysql Tutorial mongodb安装笔记【服务没有及时响应或控制请求】

mongodb安装笔记【服务没有及时响应或控制请求】

Jun 07, 2016 pm 03:28 PM
mongodb response Install control Serve notes

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使用服务方式安装

1

2

3

4

'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'

Copy after login
日志需要指定具体的文件,比如MongoLog.log 之前没有置顶就报错【服务没有及时响应或控制请求】

安装、删除服务指令

mongod --install

mongod --service

mongod --remove

mongod --reinstall

或者

1

C:\mongodb\bin\mongod.exe --remove

Copy after login

启动服务

1

net start Mongodb

Copy after login
停止服务

1

net stop Mongodb

Copy after login
测试简单JavaScript语句

1

2

3

4

5

6

7

8

9

10

11

> 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

Copy after login

下面从官网摘抄下来的普通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

1

2

3

4

5

6

7

8

CREATE TABLE users (

    id MEDIUMINT NOT NULL

        AUTO_INCREMENT,

    user_id Varchar(30),

    age Number,

    status char(1),

    PRIMARY KEY (id)

)

Copy after login

Implicitly created on first insert() operation. The primary key_idis automatically added if_id field is not specified.

1

2

3

4

5

db.users.insert( {

    user_id: "abc123",

    age: 55,

    status: "A"

 } )

Copy after login

However, you can also explicitly create a collection:

1

db.createCollection("users")

Copy after login
Seeinsert() anddb.createCollection()for more information.

1

2

ALTER TABLE users

ADD join_date DATETIME

Copy after login

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.

1

2

3

4

5

db.users.update(

    { },

    { $set: { join_date: new Date() } },

    { multi: true }

)

Copy after login
See the Data Modeling Concepts, update(), and$set for moreinformation on changing the structure of documents in acollection.

1

2

ALTER TABLE users

DROP COLUMN join_date

Copy after login

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.

1

2

3

4

5

db.users.update(

    { },

    { $unset: { join_date: "" } },

    { multi: true }

)

Copy after login
See Data Modeling Concepts, update(), and$unset for more information on changing the structure ofdocuments in a collection.

1

2

CREATE INDEX idx_user_id_asc

ON users(user_id)

Copy after login

1

db.users.ensureIndex( { user_id: 1 } )

Copy after login
See ensureIndex()andindexes for more information.

1

2

3

CREATE INDEX

       idx_user_id_asc_age_desc

ON users(user_id, age DESC)

Copy after login

1

db.users.ensureIndex( { user_id: 1, age: -1 } )

Copy after login
See ensureIndex()andindexes for more information.

1

DROP TABLE users

Copy after login

1

db.users.drop()

Copy after login
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

1

2

3

4

5

6

INSERT INTO users(user_id,

                  age,

                  status)

VALUES ("bcd001",

        45,

        "A")

Copy after login

1

2

3

4

5

db.users.insert( {

       user_id: "bcd001",

       age: 45,

       status: "A"

} )

Copy after login
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

1

2

SELECT *

FROM users

Copy after login

1

db.users.find()

Copy after login
See find()for more information.

1

2

SELECT id, user_id, status

FROM users

Copy after login

1

2

3

4

db.users.find(

    { },

    { user_id: 1, status: 1 }

)

Copy after login
See find()for more information.

1

2

SELECT user_id, status

FROM users

Copy after login

1

2

3

4

db.users.find(

    { },

    { user_id: 1, status: 1, _id: 0 }

)

Copy after login
See find()for more information.

1

2

3

SELECT *

FROM users

WHERE status = "A"

Copy after login

1

2

3

db.users.find(

    { status: "A" }

)

Copy after login
See find()for more information.

1

2

3

SELECT user_id, status

FROM users

WHERE status = "A"

Copy after login

1

2

3

4

db.users.find(

    { status: "A" },

    { user_id: 1, status: 1, _id: 0 }

)

Copy after login
See find()for more information.

1

2

3

SELECT *

FROM users

WHERE status != "A"

Copy after login

1

2

3

db.users.find(

    { status: { $ne: "A" } }

)

Copy after login
See find()and$ne for more information.

1

2

3

4

SELECT *

FROM users

WHERE status = "A"

AND age = 50

Copy after login

1

2

3

4

db.users.find(

    { status: "A",

      age: 50 }

)

Copy after login
See find()and$and for more information.

1

2

3

4

SELECT *

FROM users

WHERE status = "A"

OR age = 50

Copy after login

1

2

3

4

db.users.find(

    { $or: [ { status: "A" } ,

             { age: 50 } ] }

)

Copy after login
See find()and$or for more information.

1

2

3

SELECT *

FROM users

WHERE age > 25

Copy after login

1

2

3

db.users.find(

    { age: { $gt: 25 } }

)

Copy after login
See find()and$gt for more information.

1

2

3

SELECT *

FROM users

WHERE age < 25

Copy after login

1

2

3

db.users.find(

   { age: { $lt: 25 } }

)

Copy after login
See find()and$lt for more information.

1

2

3

4

SELECT *

FROM users

WHERE age > 25

AND   age <= 50

Copy after login

1

2

3

db.users.find(

   { age: { $gt: 25, $lte: 50 } }

)

Copy after login
See find(),$gt, and $lte formore information.

1

2

3

SELECT *

FROM users

WHERE user_id like "%bc%"

Copy after login

1

2

3

db.users.find(

   { user_id: /bc/ }

)

Copy after login
See find()and$regex for more information.

1

2

3

SELECT *

FROM users

WHERE user_id like "bc%"

Copy after login

1

2

3

db.users.find(

   { user_id: /^bc/ }

)

Copy after login
See find()and$regex for more information.

1

2

3

4

SELECT *

FROM users

WHERE status = "A"

ORDER BY user_id ASC

Copy after login

1

db.users.find( { status: "A" } ).sort( { user_id: 1 } )

Copy after login
See find()andsort()for more information.

1

2

3

4

SELECT *

FROM users

WHERE status = "A"

ORDER BY user_id DESC

Copy after login

1

db.users.find( { status: "A" } ).sort( { user_id: -1 } )

Copy after login
See find()andsort()for more information.

1

2

SELECT COUNT(*)

FROM users

Copy after login

1

db.users.count()

Copy after login

or

1

db.users.find().count()

Copy after login
See find()andcount() formore information.

1

2

SELECT COUNT(user_id)

FROM users

Copy after login

1

db.users.count( { user_id: { $exists: true } } )

Copy after login

or

1

db.users.find( { user_id: { $exists: true } } ).count()

Copy after login
See find(),count(), and$exists for more information.

1

2

3

SELECT COUNT(*)

FROM users

WHERE age > 30

Copy after login

1

db.users.count( { age: { $gt: 30 } } )

Copy after login

or

1

db.users.find( { age: { $gt: 30 } } ).count()

Copy after login
See find(),count(), and$gt for more information.

1

2

SELECT DISTINCT(status)

FROM users

Copy after login

1

db.users.distinct( "status" )

Copy after login
See find()anddistinct()for more information.

1

2

3

SELECT *

FROM users

LIMIT 1

Copy after login

1

db.users.findOne()

Copy after login

or

1

db.users.find().limit(1)

Copy after login
See find(),findOne(),andlimit()for more information.

1

2

3

4

SELECT *

FROM users

LIMIT 5

SKIP 10

Copy after login

1

db.users.find().limit(5).skip(10)

Copy after login
See find(),limit(), andskip() formore information.

1

2

3

EXPLAIN SELECT *

FROM users

WHERE status = "A"

Copy after login

1

db.users.find( { status: "A" } ).explain()

Copy after login
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

1

2

3

UPDATE users

SET status = "C"

WHERE age > 25

Copy after login

1

2

3

4

5

db.users.update(

   { age: { $gt: 25 } },

   { $set: { status: "C" } },

   { multi: true }

)

Copy after login
See update(),$gt, and $set for moreinformation.

1

2

3

UPDATE users

SET age = age + 3

WHERE status = "A"

Copy after login

1

2

3

4

5

db.users.update(

   { status: "A" } ,

   { $inc: { age: 3 } },

   { multi: true }

)

Copy after login
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.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

LG mass-produces 27-inch 480Hz QHD gaming OLED panel with record-breaking clarity and response speed LG mass-produces 27-inch 480Hz QHD gaming OLED panel with record-breaking clarity and response speed Sep 01, 2024 pm 03:37 PM

Recently, LG Display announced that its 27-inch 480Hz QHD gaming OLED panel has officially entered mass production. This panel has created a new high in refresh rate and response speed among OLED products. The 480Hz refresh rate is paired with a GtG grayscale response time of 0.02ms, which is a step further than the previous record of 0.03ms, bringing the ultimate experience to game types such as FPS and racing. . The new panel optimizes LG Display’s META Technology to improve the luminous efficiency of OLED materials. The image quality is enhanced and specular reflection is greatly reduced. The four-sided frameless design expands the field of view and brings an immersive experience. Pixel structure optimization WRGB pixel structure is optimized for gaming and document editing needs. Text display is clearer

Huawei's August service day is here: free mobile phone films and free labor costs for repairs Huawei's August service day is here: free mobile phone films and free labor costs for repairs Aug 07, 2024 pm 07:24 PM

According to news on August 3, according to Huawei’s official introduction, Huawei’s July Service Day has officially started, from August 3 to August 4. It is understood that Huawei’s service days are from the first consecutive Friday to Sunday of each month (if the weekend spans the month, it will be postponed to the next weekend). Huawei users who visit the store during the event can enjoy six exclusive benefits including free film stickers and free labor costs for repairs. Specifically: Huawei mobile phones: free film, cleaning, maintenance, and system upgrade services. Huawei tablets, laptops, wearables, earphones of designated models, and smart glasses: free appearance cleaning and maintenance services. In addition, during the event, users are not required to go to the store for equipment repairs. Pay labor fees and go to the store to purchase Huawei brand accessories, extended service packages, and personalized film products: enjoy a 10% discount on the recommended retail price. The repaired equipment cannot be repaired on the same day.

How to configure MongoDB automatic expansion on Debian How to configure MongoDB automatic expansion on Debian Apr 02, 2025 am 07:36 AM

This article introduces how to configure MongoDB on Debian system to achieve automatic expansion. The main steps include setting up the MongoDB replica set and disk space monitoring. 1. MongoDB installation First, make sure that MongoDB is installed on the Debian system. Install using the following command: sudoaptupdatesudoaptinstall-ymongodb-org 2. Configuring MongoDB replica set MongoDB replica set ensures high availability and data redundancy, which is the basis for achieving automatic capacity expansion. Start MongoDB service: sudosystemctlstartmongodsudosys

How to ensure high availability of MongoDB on Debian How to ensure high availability of MongoDB on Debian Apr 02, 2025 am 07:21 AM

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

Xiaomi's Thanksgiving Season event starts: 20% off on battery replacement for 80 mobile phone models, 50% off on cleaning of all laptop series, starting from 49.5 yuan Xiaomi's Thanksgiving Season event starts: 20% off on battery replacement for 80 mobile phone models, 50% off on cleaning of all laptop series, starting from 49.5 yuan Jul 17, 2024 am 07:45 AM

According to news from this site on July 16, Xiaomi has launched its Thanksgiving Season event today, providing preferential replacement and maintenance services for mobile phones, laptops, air conditioners, washing machines, range hoods and other accessories. The content of the activities organized by this site is as follows: The event time is from 10:00 on July 16, 2024 to 24:00 on July 25, 2024. Mobile phone battery replacement can be enjoyed at 20% off for 80 models, with official quality and original accessories. 12 models can enjoy a 20% discount on mobile phone back cover replacement starting from 79.2 yuan. Mobile phone back cover replacement, official accessories, starting from 68 yuan. It should be noted that after users place an order for the back cover replacement service on Xiaomi Mall, the color can be selected at the store. , the specific inventory is subject to the actual situation of the store. If the selected color is out of stock, there may be a delivery delay. Replace your laptop battery with a new one and enjoy 20% off on 14 models of laptops

Navicat's method to view MongoDB database password Navicat's method to view MongoDB database password Apr 08, 2025 pm 09:39 PM

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

Major update of Pi Coin: Pi Bank is coming! Major update of Pi Coin: Pi Bank is coming! Mar 03, 2025 pm 06:18 PM

PiNetwork is about to launch PiBank, a revolutionary mobile banking platform! PiNetwork today released a major update on Elmahrosa (Face) PIMISRBank, referred to as PiBank, which perfectly integrates traditional banking services with PiNetwork cryptocurrency functions to realize the atomic exchange of fiat currencies and cryptocurrencies (supports the swap between fiat currencies such as the US dollar, euro, and Indonesian rupiah with cryptocurrencies such as PiCoin, USDT, and USDC). What is the charm of PiBank? Let's find out! PiBank's main functions: One-stop management of bank accounts and cryptocurrency assets. Support real-time transactions and adopt biospecies

How to encrypt data in Debian MongoDB How to encrypt data in Debian MongoDB Apr 12, 2025 pm 08:03 PM

Encrypting MongoDB database on a Debian system requires following the following steps: Step 1: Install MongoDB First, make sure your Debian system has MongoDB installed. If not, please refer to the official MongoDB document for installation: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/Step 2: Generate the encryption key file Create a file containing the encryption key and set the correct permissions: ddif=/dev/urandomof=/etc/mongodb-keyfilebs=512

See all articles
SQL Delete Statements MongoDB remove() Statements Reference

1

2

DELETE FROM users

WHERE status = "D"

Copy after login

1

db.users.remove( { status: "D" } )

Copy after login
See remove()for more information.

1

DELETE FROM users

Copy after login

1

db.users.remove( )

Copy after login
See remove()for more information.