วิธีดาวน์โหลดและติดตั้ง MongoDB on Windows และคลาวด์

⚡ สรุปอย่างชาญฉลาด

วิธีดาวน์โหลดและติดตั้ง MongoDB on Windows and Cloud is explained as a complete setup guide. This resource covers installing MongoDB Community Server on Windowsที่ Javaสคริปต์ Python, and Ruby drivers, MongoDB Compass, configuration with import and export, a config file, and deploying MongoDB Atlas on the cloud.

  • 🪟 Windows ติดตั้ง: Download the 64-bit Community Server and run the MSI installer.
  • 🔌 ไดรเวอร์: JavaScript ships built in; add Python (pymongo) and Ruby (mongo) drivers.
  • 🧭 เข็มทิศ: ติดตั้ง MongoDB Compass GUI to manage databases visually.
  • ⚙️ การกำหนดค่า: Set the data directory, import/export CSV, and use a config file.
  • ☁️ เมฆ: ปรับใช้ MongoDB Atlas on AWS, Google Cloudหรือ Azure and connect a client.

วิธีดาวน์โหลดและติดตั้ง MongoDB

ผู้ติดตั้งสำหรับ MongoDB are available in both the 32-bit and 64-bit format. The 32-bit installers are good for development and test environments. But for production environments you should use the 64-bit installers. Otherwise, you can be limited in the amount of data that can be stored within MongoDB. It is advisable to always use the stable release for production environments.

วิธีดาวน์โหลดและติดตั้ง MongoDB on Windows

ขั้นตอนต่อไปนี้สามารถใช้เพื่อดาวน์โหลดและติดตั้ง MongoDB on Windows 10:

ขั้นตอนที่ 1) ดาวน์โหลด MongoDB ชุมชนเซิร์ฟเวอร์

ไปที่ ลิงค์ และดาวน์โหลด MongoDB เซิร์ฟเวอร์ชุมชน เราจะติดตั้งเวอร์ชัน 64 บิตสำหรับ Windows.

ดาวน์โหลดและติดตั้ง MongoDB on Windows

ขั้นตอนที่ 2) คลิกที่ตั้งค่า

Once the download is complete, open the msi file. Click Next in the start-up screen.

ดาวน์โหลดและติดตั้ง MongoDB on Windows

ขั้นตอนที่ 3) ยอมรับข้อตกลงสิทธิ์การใช้งานสำหรับผู้ใช้ปลายทาง

  1. Accept the End-User License Agreement.
  2. คลิกถัดไป

ดาวน์โหลดและติดตั้ง MongoDB on Windows

Step 4) Click on the “Complete” button

Click on the “Complete” button to install all of the components. The custom option can be used to install selective components or if you want to change the location of the installation.

ดาวน์โหลดและติดตั้ง MongoDB on Windows

ขั้นตอนที่ 5) การกำหนดค่าบริการ

  1. Select “Run service as Network Service user”. Make a note of the data directory; we will need this later.
  2. คลิกถัดไป

ดาวน์โหลดและติดตั้ง MongoDB on Windows

ขั้นตอนที่ 6) เริ่มกระบวนการติดตั้ง

คลิกที่ปุ่มติดตั้งเพื่อเริ่มการติดตั้ง

ดาวน์โหลดและติดตั้ง MongoDB on Windows

Step 7) Click Next once completed

Installation begins. Click Next once completed.

ดาวน์โหลดและติดตั้ง MongoDB on Windows

ขั้นตอนที่ 8) คลิกที่ปุ่มเสร็จสิ้น

Final step: once the installation is complete, click on the Finish button.

ดาวน์โหลดและติดตั้ง MongoDB on Windows

สวัสดีชาวโลก MongoDB: Javaไดรเวอร์สคริปต์

พนักงานขับรถใน MongoDB are used for connectivity between client applications and the database. For example, if you had a Java โปรแกรมและจำเป็นต้องเชื่อมต่อ MongoDB, then you would require to download and integrate the Java ไดรเวอร์เพื่อให้โปรแกรมสามารถทำงานร่วมกับ MongoDB ฐานข้อมูล

คนขับรถสำหรับ Javaต้นฉบับ ออกมาจากกล่อง MongoDB shell which is used to work with the MongoDB database is actually a JavaScript shell. To access it:

ขั้นตอน 1) Go to “C:\Program Files\MongoDB\Server\4.0\bin” และดับเบิลคลิกที่ mongo.exe หรืออีกวิธีหนึ่ง คุณสามารถคลิกที่ MongoDB desktop item.

สวัสดีชาวโลก MongoDB: Javaไดรเวอร์สคริปต์

ขั้นตอน 2) Enter the following program into the shell:

var myMessage='Hello World';
printjson(myMessage);

สวัสดีชาวโลก MongoDB: Javaไดรเวอร์สคริปต์

Code คำอธิบาย:

  1. เราแค่ประกาศเรื่องง่ายๆ JavaScript variable to store a string called ‘Hello World’.
  2. เรากำลังใช้วิธี printjson เพื่อพิมพ์ตัวแปรไปที่หน้าจอ

การติดตั้ง Python คนขับรถ

ขั้นตอน 1) ทำให้มั่นใจ Python is installed on the system.

ขั้นตอน 2) Install the mongo related drivers by issuing the below command:

pip install pymongo

ติดตั้งไดร์เวอร์รูบี้

ขั้นตอน 1) Ensure Ruby is installed on the system.

ขั้นตอน 2) Ensure gems is updated by issuing the command:

gem update --system

ขั้นตอน 3) Install the mongo related drivers by issuing the below command:

gem install mongo

การติดตั้ง MongoDB Compass - MongoDB เครื่องมือการจัดการ

มีเครื่องมือในตลาดที่พร้อมสำหรับการจัดการ MongoDB- เครื่องมือที่ไม่ใช่เชิงพาณิชย์อย่างหนึ่งก็คือ MongoDB Compass. Some of the features of Compass are given below:

  1. Full power of the Mongo shell
  2. เปลือกหอยหลายอัน
  3. ผลลัพธ์หลายรายการ

ขั้นตอน 1) ไปที่ ลิงค์ and click download.

การติดตั้ง MongoDB Compass

ขั้นตอน 2) Enter details in the popup and click submit.

การติดตั้ง MongoDB Compass

ขั้นตอน 3) Double click on the downloaded file.

การติดตั้ง MongoDB Compass

ขั้นตอน 4) Installation will auto-start.

การติดตั้ง MongoDB Compass

ขั้นตอน 5) Compass will launch with a Welcome screen.

การติดตั้ง MongoDB Compass

ขั้นตอน 6) Keep the privacy settings as default and click “Start Using Compass”.

การติดตั้ง MongoDB Compass

ขั้นตอน 7) You will see the home screen with a list of current databases.

การติดตั้ง MongoDB Compass

MongoDB การกำหนดค่า การนำเข้า และการส่งออก

ก่อนที่จะเริ่ม MongoDB เซิร์ฟเวอร์ลักษณะสำคัญประการแรกคือการกำหนดค่าไดเร็กทอรีข้อมูลที่ทั้งหมด MongoDB data will be stored. This can be done in the following way:

MongoDB การกำหนดค่า การนำเข้า และการส่งออก

คำสั่งด้านบน 'md \data\db' สร้างไดเร็กทอรีชื่อ \data\db ในตำแหน่งปัจจุบันของคุณ MongoDB จะสร้างฐานข้อมูลในตำแหน่งนี้โดยอัตโนมัติ เนื่องจากนี่คือตำแหน่งเริ่มต้นสำหรับ MongoDB เพื่อเก็บข้อมูล เราเพียงแค่ต้องแน่ใจว่าไดเร็กทอรีนั้นมีอยู่ดังนั้น MongoDB สามารถค้นหาได้เมื่อมันเริ่ม

การนำเข้าข้อมูลเข้าสู่ MongoDB ทำได้โดยใช้คำสั่ง “mongoimport” ตัวอย่างต่อไปนี้จะแสดงวิธีดำเนินการนี้

ขั้นตอน 1) Create a CSV file called data.csv and put the following data in it:

Employeeid,EmployeeName
1,Guru99
2,Mohan
3,Smith

So in the above example, we are assuming we want to import 3 documents into a collection called data. The first row is called the header line, which will become the field names of the collection.

ขั้นตอน 2) Issue the mongoimport command.

MongoDB การกำหนดค่า การนำเข้า และการส่งออก

Code คำอธิบาย:

  1. We are specifying the db option to say which database the data should be imported to.
  2. The type option is to specify that we are importing a csv file.
  3. Remember that the first row is called the header line, which will become the field names of the collection; that is why we specify the –headerline option. And then we specify our data.csv file.

เอาท์พุต

MongoDB การกำหนดค่า การนำเข้า และการส่งออก

ผลลัพธ์แสดงให้เห็นชัดเจนว่ามีการนำเข้าเอกสาร 3 ฉบับเข้ามา MongoDB.

การส่งออก MongoDB is done by using the mongoexport command.

MongoDB การกำหนดค่า การนำเข้า และการส่งออก

Code คำอธิบาย:

  1. เรากำลังระบุตัวเลือก db เพื่อบอกว่าฐานข้อมูลใดที่ควรส่งออกข้อมูล
  2. We are specifying the collection option to say which collection to use.
  3. The third option is to specify that we want to export to a csv file.
  4. ประการที่สี่คือการระบุว่าควรส่งออกฟิลด์ใดของคอลเลกชัน
  5. ตัวเลือก –out ระบุชื่อของไฟล์ csv ที่จะส่งออกข้อมูลไป

เอาท์พุต

MongoDB การกำหนดค่า การนำเข้า และการส่งออก

ผลลัพธ์แสดงให้เห็นอย่างชัดเจนว่ามีการส่งออก 3 รายการ MongoDB.

การกำหนดค่า MongoDB เซิร์ฟเวอร์พร้อมไฟล์กำหนดค่า

One can configure the mongod server instance to start up with a configuration file. The configuration file contains settings that are equivalent to the mongod command-line options. For example, suppose you wanted MongoDB to store all its logging information to a custom location, then follow the below steps:

ขั้นตอน 1) Create a file called “mongod.conf” and store the below information in the file.

การกำหนดค่า MongoDB เซิร์ฟเวอร์พร้อมไฟล์กำหนดค่า

  1. The first line of the file specifies that we want to add configuration for the system log file, that is where the information about what the server is doing goes, in a custom log file.
  2. ตัวเลือกที่สองคือการระบุว่าตำแหน่งนั้นจะเป็นไฟล์
  3. This mentions the location of the log file.
  4. logAppend: “true” หมายถึงเพื่อให้แน่ใจว่าข้อมูลบันทึกยังคงถูกเพิ่มลงในไฟล์บันทึก หากคุณใส่ค่าเป็น "false" ไฟล์จะถูกลบและสร้างใหม่ทุกครั้งที่เซิร์ฟเวอร์เริ่มทำงานอีกครั้ง

ขั้นตอน 2) Start the mongod server process and specify the above created configuration file as a parameter. The screenshot of how this can be done is shown below.

การกำหนดค่า MongoDB เซิร์ฟเวอร์พร้อมไฟล์กำหนดค่า

Once the above command is executed, the server process will start using this configuration file, and if you go to the /etc directory on your system, you will see the mongod.log file created. The below snapshot shows an example of what a log file would look like.

การกำหนดค่า MongoDB เซิร์ฟเวอร์พร้อมไฟล์กำหนดค่า

วิธีการติดตั้ง MongoDB บนระบบคลาวด์ (AWS, Google, Azure)

You do not need to install the MongoDB server and configure it. You can deploy a MongoDB เซิร์ฟเวอร์ Atlas บนคลาวด์บนแพลตฟอร์มเช่น AWS Google Cloudและ Azure, and connect to the instance using a client. Below are the detailed steps:

ขั้นตอน 1) ไปที่ ลิงค์.

  1. ป้อนรายละเอียดส่วนบุคคล
  2. เห็นด้วยกับข้อตกลง
  3. Click the button “Get Started Free”

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 2) Click “Build my first cluster”.

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 3) คุณสามารถเลือกระหว่าง AWS, Google Cloudและ Azure as your cloud provider. In this tutorial, we will use AWS, which is set by default. Make no other changes on the page and click “Create Cluster"

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 4) Cluster creation takes some time.

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 5) After some time you will see the cluster ready.

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 6) Click Security > Add new user.

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 7) ในหน้าจอถัดไป:

  1. ป้อนข้อมูลรับรองผู้ใช้
  2. กำหนดสิทธิพิเศษ
  3. Click the Add User button

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 8) In the dashboard, click the connect button.

  1. ไวท์ลิสต์การเชื่อมต่อ IP ของคุณ
  2. เลือกวิธีการเชื่อมต่อ

การติดตั้ง MongoDB บนคลาวด์

ขั้นตอน 9) Select the connection method of your choice to connect to the MongoDB เซิร์ฟเวอร์

การติดตั้ง MongoDB บนคลาวด์

คำถามที่พบบ่อย

Yes. AI assistants can generate mongod configuration files, explain connection errors, and suggest fixes for driver or service issues. You should still verify commands against the official MongoDB documentation before applying them.

ใช่. MongoDB Atlas includes Atlas Vector Search and AI integrations that let you build semantic search and retrieval-augmented generation apps. It stores embeddings alongside documents, removing the need for a separate vector database.

ใช่. MongoDB Community Server is free and open source for Windows, macOSและ Linux MongoDB Atlas also provides a free cloud tier, while Enterprise Edition adds paid advanced features and support.

Community Server is installed and managed on your own machine or server. Atlas is a fully managed cloud service that handles setup, scaling, backups, and security on AWS, Google Cloudหรือ Azure.

สรุปโพสต์นี้ด้วย: