mongodb-dba-workshop

ฝึกเชื่อมต่อ Cluster บน Atlas ด้วย Mongo Shell และใช้คำสั่งพื้นฐาน

เปิด Terminal หรือ Command Prompt แล้วให้เรารันคำสั่งนี้

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

รายละเอียด

คำสั่งพื้นฐาน

แสดงฐานข้อมูลทั้งหมด

show dbs

เลือกฐานข้อมูล

use <db>

แสดง collection ทั้งหมดในฐานข้อมูลที่ใช้งานอยู่

show collections

แสดง document ใน collection

db.<collections>.find()

แถม

ลอง query ด้วย .pretty() ดู

db.<collections>.find().pretty()