mongodb學(xué)習(xí)

1. mongodb數(shù)據(jù)庫創(chuàng)建和刪除

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

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

這兩個(gè)文件夾是自己隨意創(chuàng)建的mongodb\mydata,輸入上面的指令后開始啟動mongodb服務(wù)

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 <address> 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: <unsharded>
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: <unsharded>
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: <unsharded>
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: <unsharded>
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: <unsharded>
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: <unsharded>
2019-12-11T20:30:06.829+0800 I  SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>

2.找到bin文件夾點(diǎn)擊mongo.exe啟動mongodb數(shù)據(jù)庫,即可指令操作數(shù)據(jù)庫


image.png

3,數(shù)據(jù)可視化


image.png

指令創(chuàng)建數(shù)據(jù)庫,空數(shù)據(jù)庫不顯示,需要插入內(nèi)容才顯示

use hccdatabase


image.png

刪除數(shù)據(jù)庫

db.dropDatabase()意味著數(shù)據(jù)庫刪除數(shù)據(jù)庫


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容