• 欢迎光临~

MongoDB: MongoDB 安装和使用

开发技术 开发技术 2022-10-15 次浏览

MongoDB 安装和使用

 

 

 

 

一、MongoDB 准备工作:

 

 

  1、MongoDB 下载:

    1.1、mongodb 下载(version-windows-zip):https://www.mongodb.com/try/download/community

    1.2、shell 下载(version-windows-zip):https://www.mongodb.com/try/download/compass

 

 

  2、建立目录:

    2.1、MongoDB安装目录:D:toolswebdbmongodb

    2.2、MongoDB安装根目录:D:toolswebdbmongodbmongodb602

    2.3、数据存储目录:D:toolswebdbmongodbmongodb_datadata

    2.4、日志存储目录:D:toolswebdbmongodbmongodb_datalog

    2.5、建立空文件mogod.log:D:toolswebdbmongodbmongodb_datalogmongod.log

 

 

  3、配置文件(D:toolswebdbmongodbmongodb602mongod.cfg)

    3.1、yaml入门教程:https://www.runoob.com/w3cnote/yaml-intro.html

    3.2、配置文件内容(mongod.cfg):

storage:
    dbPath: D:toolswebdbmongodbmongodb_datadata
systemLog:
    destination: file
    path: D:toolswebdbmongodbmongodb_datalogmongod.log

 

 

 

 

二、MongoDB:安装服务、服务开启、服务关闭、卸载服务

 

 

  1、MongoDB:安装服务、服务开启、服务关闭、卸载服务:

G:tmpWorkspacesdatabases>mongod  --config "D:toolswebdbmongodbmongodb602mongod.cfg"  --install
{"t":{"$date":"2022-10-14T18:03:15.987Z"},"s":"I",  "c":"CONTROL",  "id":20697,   "ctx":"-","msg":"Renamed existing log file","attr":{"oldLogPath":"D:\tools\web\db\mongodb\mongodb_data\log\mongod.log","newLogPath":"D:\tools\web\db\mongodb\mongodb_data\log\mongod.log.2022-10-14T18-03-15"}}

G:tmpWorkspacesdatabases>net start MongoDB
The MongoDB service is starting..
The MongoDB service was started successfully.


G:tmpWorkspacesdatabases>net stop  MongoDB
The MongoDB service is stopping.
The MongoDB service was stopped successfully.


G:tmpWorkspacesdatabases>mongod --remove
{"t":{"$date":"2022-10-15T02:12:00.988+08:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"-","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-10-15T02:12:05.315+08:00"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"-","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2022-10-15T02:12:05.316+08:00"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"thread1","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2022-10-15T02:12:05.322+08:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}}
{"t":{"$date":"2022-10-15T02:12:05.322+08:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2022-10-15T02:12:05.322+08:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2022-10-15T02:12:05.323+08:00"},"s":"I",  "c":"CONTROL",  "id":23307,   "ctx":"thread1","msg":"Trying to remove Windows service","attr":{"name":"MongoDB"}}
{"t":{"$date":"2022-10-15T02:12:05.325+08:00"},"s":"I",  "c":"CONTROL",  "id":23312,   "ctx":"thread1","msg":"Service removed","attr":{"serviceName":"MongoDB"}}

G:tmpWorkspacesdatabases>

 

 

  2、MongoDB:安装服务、服务开启、服务关闭、卸载服务 (操作实例)

MongoDB: MongoDB 安装和使用

 

 

 

 

三、MongoDB 使用教程

 

 

  1、MongoDB 教程(菜鸟教程):https://www.runoob.com/mongodb/mongodb-tutorial.html

 

程序员灯塔
转载请注明原文链接:MongoDB: MongoDB 安装和使用
喜欢 (0)
违法和不良信息举报电话:022-22558618 举报邮箱:dljd@tidljd.com