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; 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章