MongoDB随手记2——安装db

以下为学习笔记:

1. 去MongoDB download center下载适合电脑操作系统的安装文件: https://www.mongodb.com/download-center#enterprise

2. 找到.msi文件双击运行按照步骤进行安装即可。

Set up the MongoDB environment.

MongoDB requires a data directory to store all data. MongoDB’s default data directory path is the absolute path \data\db on the drive from which you start MongoDB. Create this folder by running the following command in a Command Prompt:

md \data\db

You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:

"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath d:\test\mongodb\data

If your path includes spaces, enclose the entire path in double quotes, for example:

"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath "d:\test\mongo db data"

You may also specify the dbpath in a configuration file.

Start MongoDB.

To start MongoDB, run mongod.exe. For example, from the Command Prompt:

"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe"

This starts the main MongoDB database process. The waiting for connections message in the console output indicates that the mongod.exe process is running successfully.

Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features” of C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe from communicating on networks. All users should select Private Networks, such as my home or work network and click Allow access. For additional information on security and MongoDB, please see the Security Documentation.

3

Connect to MongoDB.

To connect to MongoDB through the mongo.exe shell, open another Command Prompt.

"C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe"

If you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.

4

Begin using MongoDB.

To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.

Before deploying MongoDB in a production environment, consider the Production Notes document.

Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.

Configure a Windows Service for MongoDB Enterprise

1

Open an Administrator command prompt.

Press the Win key, type cmd.exe, and press Ctrl + Shift + Enter to run the Command Prompt as Administrator.

Execute the remaining steps from the Administrator command prompt.

2

Create directories.

Create directories for your database and log files:

mkdir c:\data\db
mkdir c:\data\log

3

Create a configuration file.

Create a configuration file. The file must set systemLog.path. Include additional configuration options as appropriate.

For example, create a file at C:\Program Files\MongoDB\Server\3.6\mongod.cfg that specifies both systemLog.path and storage.dbPath:

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db

4

Install the MongoDB service.

Important

Run all of the following commands in Command Prompt with “Administrative Privileges”.

Install the MongoDB service by starting mongod.exe with the --install option and the -config option to specify the previously created configuration file.

"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --config "C:\Program Files\MongoDB\Server\3.4\mongod.cfg" --install

To use an alternate dbpath, specify the path in the configuration file (e.g. C:\mongodb\mongod.cfg) or on the command line with the --dbpath option.

If needed, you can install services for multiple instances of mongod.exe or mongos.exe. Install each service with a unique --serviceName and --serviceDisplayName. Use multiple instances only when sufficient system resources exist and your system design requires it.

5

Start the MongoDB service.

net start MongoDB

6

Stop or remove the MongoDB service as needed.

To stop the MongoDB service use the following command:

net stop MongoDB

To remove the MongoDB service use the following command:

"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --remove

Manually Create a Windows Service for MongoDB Enterprise

You can set up the MongoDB server as a Windows Service that starts automatically at boot time.

The following procedure assumes you have installed MongoDB using the .msi installer with the path C:\Program Files\MongoDB\Server\3.4\.

If you have installed in an alternative directory, you will need to adjust the paths as appropriate.

1

Open an Administrator command prompt.

Press the Win key, type cmd.exe, and press Ctrl + Shift + Enter to run the Command Prompt as Administrator.

Execute the remaining steps from the Administrator command prompt.

2

Create directories.

Create directories for your database and log files:

mkdir c:\data\db
mkdir c:\data\log

3

Create a configuration file.

Create a configuration file. The file must set systemLog.path. Include additional configuration options as appropriate.

For example, create a file at C:\Program Files\MongoDB\Server\3.6\mongod.cfg that specifies both systemLog.path and storage.dbPath:

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db

4

Create the MongoDB service.

Create the MongoDB service.

sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.6\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

sc.exe requires a space between “=” and the configuration values (eg “binPath= “), and a “" to escape double quotes.

If successfully created, the following log message will display:

[SC] CreateService SUCCESS

5

Start the MongoDB service.

net start MongoDB

6

Stop or remove the MongoDB service as needed.

To stop the MongoDB service, use the following command:

net stop MongoDB

To remove the MongoDB service, first stop the service and then run the following command:

sc.exe delete MongoDB
时间: 2024-10-28 20:09:26

MongoDB随手记2——安装db的相关文章

PHP学习之-Mongodb在Windows下安装及配置

Mongodb在Windows下安装及配置 1.下载 下载地址:http://www.mongodb.org/ 建议下载zip版本. 2.安装 下载windows版本安装就和普通的软件一样,直接下一步就可以了. 3.启动服务 启动服务之前先创建存放数据库文件的文件夹然后再启动服务. #创建一个MongoDB服务mongod --logpath "D:\development\db\mongodb-win32-x86_64-2008plus-2.6.7\data\log\mongodb.log&q

mongodb在windows下安装教程

原文来自:http://www.cnblogs.com/lecaf/archive/2013/08/23/mongodb.html 红字为本人加 一.首先安装mongodb 1.下载地址:http://www.mongodb.org/downloads 2.解压缩到自己想要安装的目录,比如d:\mongodb 3.创建文件夹d:\mongodb\data\db.d:\mongodb\data\log,分别用来安装db和日志文件,在log文件夹下创建一个日志文件MongoDB.log,即d:\mo

mongodb 3.2.5安装过程详细记录

2016-10-19    mongodb 3.2.5安装 1 准备安装介质 安装介质下载: mongodb的安装方式,我通常使用二进制包的方式,内网不能配置连接外网的yum源: 官方建议的mongodb下载地址为:   Downloads.mongodb.org 但实际上,这个地址,很难找到下载表,正常下载,通常可以用下面的下载地址选择下载: 我这里下载的是: 3.2.5 版本对应的 mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8.tgz 如果将整个

MongoDB 3.0.4 安装

1.首先到官网(mongodb)下载合适的安装包,目前最新版本为3.0.4 我电脑是win7系统64位,下载Windows 64-bit 2008 R2+版本,下载完成后安装到D:\MongoDB目录下 2.安装完成之后还不能使用,需要下载 KB2731284 这个补丁,不知道其它系统是否需要安装,安装完成后,重新起动电脑 3.mongodb安装目录如下D:\MongoDB\Server\3.0,创建data文件夹,在data文件夹下创建db,log文件夹 4.切换到D:\MongoDB\Ser

MongoDB的快速手动安装

转自:http://www.cnblogs.com/Showshare/p/mongodb-quickly-install.html 上一篇文章<MongoDB.WebIDE:升级版的Mongodb管理工具>漏了点东西:就是关于MongoDB主从库的安装配置和启动.网上关于MongoDB的安装有大量的文章供大家学习.我这里提供一个Windows环境下MongoDB主从库的快速手动安装的方法,只需要三步即可. 先下载的安装包,解压缩后找到bin文件夹,将bin文件夹拷贝至你自己的安装目录(从本机

一、MongoDB的下载、安装与部署

1.什么是MongoDB? 它是介于关系型数据库和非关系型数据库之间的一种NoSQL数据库,用C++编写,是一款集敏捷性.可伸缩性.扩展性于一身的高性能的面向文档的通用数据库. 2.为什么要用MongoDB? 它具有以下几个特征: a).灵活的文档数据模型 可以非常容易的存储不同结构的的数据,并且还能动态的修改这些数据的源结构模式 b).可伸缩可扩展性 从单个服务器到数千个节点,MongoDB可以很轻松的进行水平扩展,部署多个数据中心 c).二级索引 包括在完全一致的任何字段上的索引.地理空间.

Mongodb在Linux下安装及配置

1.下载mongodb的linux版本(注意32位和64位的区别),下载地址:http://www.mongodb.org/downloads 2.将下载的mongodb安装文件mongodb-linux-i686-1.6.5.tgz放到/usr/local/下 3.解压tar -zxvf mongodb-linux-i686-1.6.5.tgz 重命名mv mongodb-linux-i686-1.6.5.tgz mongodb 4,创建数据库文件目录,默认为/data/db,我把数据库文件目

MongoDB 学习笔记一 安装以及基础命令

一.MongoDB安装配置 1.获取最新版本: wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.2.tgz 2.解压缩即可执行 tar zxvf mongodb-linux-x86_64-2.0.2.tgz tar zxvf mongodb-linux-x86_64-2.0.2.tgz cd /usr/mongodb-linux-x86_64-2.0.2/bin 但是在运行前,需要创建mongodb需要的存放数据和日志的

MongoDB在Windows下安装配置

MongoDB在Windows下安装配置 2012-08-17 09:48 lsc183 博客园 我要评论(0) 字号:T | T 这里给大家分享的是MongoDB在Windows下安装配置,包括如何解压缩.建立工作目录和设置系统变量等等. AD:2014WOT全球软件技术峰会北京站 课程视频发布 安装文件:官方网站 http://www.mongodb.org/downloads 选择对应系统的文件下载. 一.解压缩文件. 将压缩包解压,在D盘创建文件夹MongoDB,将压缩包中所有的.exe