mongodb window安装到操作

1.按照参照

https://blog.csdn.net/muguli2008/article/details/80591256

2.去C:\Windows\System32  目录下  右击cmd 选择已管理员身份运行

   否则报错 Error connecting to the Service Control Manager: 拒绝访问。 (5)

3.

Microsoft Windows [版本 10.0.17763.1098]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Windows\system32>mongod.exe --dbpath=d:/mongo/db --logpath=d:/mongo/log/log.txt --install

C:\Windows\system32>sc create mongodb binPath= "C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe --service --dbpath D:\mongodb\data --logpath=d:\mongodb\log\mongodb.log --logappend --directoryperdb"
[SC] CreateService 失败 1073:

指定的服务已存在。


C:\Windows\system32>
C:\Windows\system32>mongo
MongoDB shell version v4.2.5-41-g4a806ff
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("7297da0e-33dc-442d-b9ce-beeda26faa7c") }
MongoDB server version: 4.2.5-41-g4a806ff
Server has startup warnings:
2020-04-08T20:23:23.127+0800 I  CONTROL  [initandlisten]
2020-04-08T20:23:23.127+0800 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-04-08T20:23:23.127+0800 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-04-08T20:23:23.127+0800 I  CONTROL  [initandlisten]
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
>

4. 

5.操作库 建库,建表,改表,删表,查表

> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> use test;
switched to db test
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> db
test
> db.createCollection('goods');
{ "ok" : 1 }
> show tables;
goods
> db.goods.renameColltion('shop');
2020-04-08T20:43:44.699+0800 E  QUERY    [js] uncaught exception: TypeError: db.goods.renameColltion is not a function :
@(shell):1:1
> db.goods.renameCollection('shop')
{ "ok" : 1 }
> show tables;
shop
> db.createCollection('user');
{ "ok" : 1 }
> db.createCollection('user1');
{ "ok" : 1 }
> show tables;
shop
user
user1
> db.shop.drop();
true
> show tables;
user
user1
>

6.Curd; 

发布了173 篇原创文章 · 获赞 29 · 访问量 29万+

猜你喜欢

转载自blog.csdn.net/qq_29058883/article/details/105396377
今日推荐