mongodb学习

1. mongodb数据库创建和删除

1,找到mongodb的bin文件地址输入:

C:\Program Files\MongoDB\Server\4.2\bin>mongod.exe --dbpath C:\Users\Administrator\Desktop\mongodb\mydata

这两个文件夹是自己随意创建的mongodb\mydata,输入上面的指令后开始启动mongodb服务

2019-12-11T20:25:05.557+0800 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-12-11T20:25:05.563+0800 I  CONTROL  [initandlisten] MongoDB starting : pid=15588 port=27017 dbpath=C:\Users\Administrator\Desktop\mongodb\mydata 64-bit host=LAPTOP-J8NGUK7R
2019-12-11T20:25:05.563+0800 I  CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-12-11T20:25:05.563+0800 I  CONTROL  [initandlisten] db version v4.2.1
2019-12-11T20:25:05.563+0800 I  CONTROL  [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-12-11T20:25:05.563+0800 I  CONTROL  [initandlisten] allocator: tcmalloc
2019-12-11T20:25:05.564+0800 I  CONTROL  [initandlisten] modules: none
2019-12-11T20:25:05.564+0800 I  CONTROL  [initandlisten] build environment:
2019-12-11T20:25:05.564+0800 I  CONTROL  [initandlisten]     distmod: 2012plus
2019-12-11T20:25:05.564+0800 I  CONTROL  [initandlisten]     distarch: x86_64
2019-12-11T20:25:05.564+0800 I  CONTROL  [initandlisten]     target_arch: x86_64
2019-12-11T20:25:05.564+0800 I  CONTROL  [initandlisten] options: { storage: { dbPath: "C:\Users\Administrator\Desktop\mongodb\mydata" } }
2019-12-11T20:25:05.573+0800 I  STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3538M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2019-12-11T20:25:05.633+0800 I  STORAGE  [initandlisten] WiredTiger message [1576067105:632465][15588:140708381282912], txn-recover: Set global recovery timestamp: (0,0)
2019-12-11T20:25:05.645+0800 I  RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-12-11T20:25:05.666+0800 I  STORAGE  [initandlisten] Timestamp monitor starting
2019-12-11T20:25:05.680+0800 I  CONTROL  [initandlisten]
2019-12-11T20:25:05.680+0800 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-12-11T20:25:05.681+0800 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-12-11T20:25:05.681+0800 I  CONTROL  [initandlisten]
2019-12-11T20:25:05.681+0800 I  CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2019-12-11T20:25:05.682+0800 I  CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2019-12-11T20:25:05.683+0800 I  CONTROL  [initandlisten] **          Start the server with --bind_ip 
to specify which IP 2019-12-11T20:25:05.683+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 2019-12-11T20:25:05.684+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 2019-12-11T20:25:05.687+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 2019-12-11T20:25:05.687+0800 I CONTROL [initandlisten] 2019-12-11T20:25:05.691+0800 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: 1efb4ecb-129f-47bf-b788-1a59dc8b3fdc and options: { uuid: UUID("1efb4ecb-129f-47bf-b788-1a59dc8b3fdc") } 2019-12-11T20:25:05.721+0800 I INDEX [initandlisten] index build: done building index _id_ on ns admin.system.version 2019-12-11T20:25:05.722+0800 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: 2019-12-11T20:25:05.723+0800 I COMMAND [initandlisten] setting featureCompatibilityVersion to 4.2 2019-12-11T20:25:05.728+0800 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: 2019-12-11T20:25:05.729+0800 I STORAGE [initandlisten] Flow Control is enabled on this deployment. 2019-12-11T20:25:05.729+0800 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: 2019-12-11T20:25:05.730+0800 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: c6c9dd2e-b027-4f4b-ba58-4a8d9002f53e and options: { capped: true, size: 10485760 } 2019-12-11T20:25:05.751+0800 I INDEX [initandlisten] index build: done building index _id_ on ns local.startup_log 2019-12-11T20:25:05.751+0800 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: 2019-12-11T20:25:06.825+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/Users/Administrator/Desktop/mongodb/mydata/diagnostic.data' 2019-12-11T20:25:06.828+0800 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: 2019-12-11T20:25:06.829+0800 I CONTROL [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist 2019-12-11T20:25:06.830+0800 I STORAGE [LogicalSessionCacheRefresh] createCollection: config.system.sessions with provided UUID: 05a63ae0-6525-4be0-8ac7-27c444763519 and options: { uuid: UUID("05a63ae0-6525-4be0-8ac7-27c444763519") } 2019-12-11T20:25:06.830+0800 I NETWORK [initandlisten] Listening on 127.0.0.1 2019-12-11T20:25:06.834+0800 I NETWORK [initandlisten] waiting for connections on port 27017 2019-12-11T20:25:06.863+0800 I INDEX [LogicalSessionCacheRefresh] index build: done building index _id_ on ns config.system.sessions 2019-12-11T20:25:06.884+0800 I INDEX [LogicalSessionCacheRefresh] index build: starting on config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 } using method: Hybrid 2019-12-11T20:25:06.884+0800 I INDEX [LogicalSessionCacheRefresh] build may temporarily use up to 500 megabytes of RAM 2019-12-11T20:25:06.885+0800 I INDEX [LogicalSessionCacheRefresh] index build: collection scan done. scanned 0 total records in 0 seconds 2019-12-11T20:25:06.889+0800 I INDEX [LogicalSessionCacheRefresh] index build: inserted 0 keys from external sorter into index in 0 seconds 2019-12-11T20:25:06.894+0800 I INDEX [LogicalSessionCacheRefresh] index build: done building index lsidTTLIndex on ns config.system.sessions 2019-12-11T20:25:07.003+0800 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: 2019-12-11T20:30:06.829+0800 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version:

2.找到bin文件夹点击mongo.exe启动mongodb数据库,即可指令操作数据库


image.png

3,数据可视化


image.png

指令创建数据库,空数据库不显示,需要插入内容才显示

use hccdatabase


image.png

删除数据库

db.dropDatabase()意味着数据库删除数据库


image.png

你可能感兴趣的:(mongodb学习)