Start and operate MongoDB (CLI) under Windows

Source: Internet
Author: User
Tags mongodb server

Tag: The source Path command executes Ash CTI requires a folder query

1. Start the MongoDB server

Locate the installation directory under the Bin folder and execute the following command

# 默认路径(安装路径\data\db),默认端口(27017)mongod.exe# 如果需要改变数据库路径和端口则改为mongod.exe --dbpath D:\mongodb\data --port 10086# 修改了启动端口,连接的时候也要指明端口mongo.exe# 连接从10086端口启动的mongoDB数据库
2. Operational database
View all Databases
show dbs
View the current database
db
Create/Switch database
use# 不存在则创建,存在则切换到该数据库
Create a collection for a database
db.createCollection("collectionName")
inserting a document
into the collection
db.collectionName.insert({"key":"value"})
querying a document in a collection
db.collectionName.findOne# 返回集合中的第一条文档db.collectionName.find# 返回集合中的所有文档
Delete all documents in the collection
db.collectionName.remove({})

Start and operate MongoDB (CLI) under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.