basic mongodb

本文详细介绍了MongoDB的安装步骤及配置方法,包括如何指定数据存储路径和使用目录每数据库存储模式。同时,提供了MongoDB客户端mongo的基本使用教程,如连接服务器、选择数据库、创建集合和插入文档等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="utf-8"?> basic mongodb

basic mongodb

Components

mongod

mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data format, and performs background management operations.

--dbpath <path> Specify a directory for the mongod instance to store its data. Typical locations include: /srv/mongodb, /var/lib/mongodb or /opt/mongodb

Unless specified, mongod will look for data files in the default /data/db directory. (Windows systems use the \data\db direc‐ tory.) If you installed using a package management system. Check the /etc/mongodb.conf file provided by your packages to see the configuration of the dbpath.

--directoryperdb Alters the storage pattern of the data directory to store each database's files in a distinct folder. This option will create directories within the --dbpath named for each directory.

Use this option in conjunction with your file system and device configuration so that MongoDB will store data on a number of distinct disk devices to increase write throughput or disk capacity.

mongo

http://docs.mongodb.org/manual/tutorial/getting-started/

mongo

By default, mongo looks for a database server listening on port 27017 on the localhost interface. To connect to a server on a different port or interface, use the --port and --host options.

Select a database
db

show dbs

use mydb

Create a Collection and Insert Documents
j = { name : "mongo" }
k = { x : 3 }

db.testData.insert( j )
db.testData.insert( k )

show collections

db.testData.find()

Post by: Jalen Wang (转载请注明出处)

转载于:https://www.cnblogs.com/jalenwang/p/3405548.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值