win10下,安装moogose环境

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shakdy/article/details/82925386

第一步:下载moogose安装包
moogose官方下载

第二步:测试是否启动了moogose
以管理员身份打开命令行,cd 到安装目录的 bin 文件夹下

F:\MongoDB\Server\4.0\bin>net start mongodb
请求的服务已经启动。

请键入 NET HELPMSG 2182 以获得更多的帮助。

打开浏览器,搜索

http://localhost:27017/

页面显示:
It looks like you are trying to access MongoDB over HTTP on the native driver port.

第四步:创建数据库
以管理员身份打开命令行,cd 到安装目录的 bin 文件夹下

F:\MongoDB\Server\4.0\bin>mongo
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> use happy_come_healthy
switched to db happy_come_healthy
> db.createCollection('happy_come_healthy')
{ "ok" : 1 }
> show dbs
admin               0.000GB
config              0.000GB
happy_come_healthy  0.000GB
local               0.000GB
>

注意:当你使用“use happy_come_healthy”切换到名为happy_come_healthy的数据库时,实际上什么也没发生,只有当你调用了db.createCollection之后,新的数据库才被保存,然后你使用“show dbs”就可以看到新建的库。

删除数据库
删除数据库需要切换到指定的库,然后调用dropDatabase()。如下:

> show dbs
admin               0.000GB
config              0.000GB
happy_come_healthy  0.000GB
local               0.000GB
> use happy_come_healthy
switched to db happy_come_healthy
> db.dropDatabase()
{ "dropped" : "happy_come_healthy", "ok" : 1 }
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
>

参考资料:
Node.js开发入门——MongoDB与Mongoose
MongoDB4.0在windows下的安装与服务配置

猜你喜欢

转载自blog.csdn.net/shakdy/article/details/82925386
今日推荐