• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

MongoDB Glossary – CLI

January 2, 2024

MongoDB Glossary – CLI

MongoDB is a popular NoSQL database that offers high performance, scalability, and flexibility. It is widely used by developers and organizations for various applications. In this article, we will explore the MongoDB Command Line Interface (CLI) and its essential commands.

What is the MongoDB CLI?

The MongoDB CLI is a powerful tool that allows users to interact with MongoDB databases through the command line. It provides a convenient way to perform administrative tasks, query data, and manage databases and collections.

Getting Started with the MongoDB CLI

To use the MongoDB CLI, you need to have MongoDB installed on your system. Once installed, you can open a command prompt or terminal and start using the CLI.

To connect to a MongoDB server, use the following command:

mongo

This command will connect to the default MongoDB server running on localhost. If you are connecting to a remote server or using a different port, you can specify the connection details as follows:

mongo --host <hostname> --port <port>

Basic MongoDB CLI Commands

Once connected to the MongoDB server, you can start executing various commands. Here are some of the essential commands:

Show Databases

To view the list of databases, use the following command:

show databases

This command will display all the databases available on the server.

Use a Database

To switch to a specific database, use the following command:

use <database_name>

This command will switch to the specified database, allowing you to perform operations on it.

Show Collections

To view the collections within a database, use the following command:

show collections

This command will display all the collections present in the current database.

Query Documents

To query documents from a collection, use the following command:

db.<collection_name>.find()

This command will retrieve all the documents from the specified collection.

Insert Documents

To insert a document into a collection, use the following command:

db.<collection_name>.insertOne({<document_data>})

This command will insert a single document into the specified collection.

Update Documents

To update documents in a collection, use the following command:

db.<collection_name>.updateOne({<filter>}, {<update>})

This command will update a single document that matches the specified filter.

Delete Documents

To delete documents from a collection, use the following command:

db.<collection_name>.deleteOne({<filter>})

This command will delete a single document that matches the specified filter.

Conclusion

The MongoDB CLI is a powerful tool for managing MongoDB databases and performing various operations. It provides a convenient way to interact with MongoDB through the command line. By mastering the essential commands, you can efficiently work with MongoDB and leverage its capabilities for your applications.

For more information about VPS hosting and how it can benefit your MongoDB deployments, check out Server.HK.

Recent Posts

  • How to Migrate from CentOS 8 to AlmaLinux or Rocky Linux Safely
  • CentOS Server Performance Tuning: Optimization Techniques for 2026
  • How to Configure SELinux in CentOS Without Breaking Your System (CentOS Stream 9/10 – 2026)
  • Managing Users and Permissions in CentOS Stream: Best Practices (CentOS Stream 9/10 – 2026)
  • How to Set Up Nginx on CentOS Stream for High-Performance Web Hosting

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot