Skip to content

mongodb

Database Management CLI: Equivalence in MySQL, PostgreSQL, and MongoDB

Introduction

Database management and querying are critical tasks for developers and database administrators. This guide explores syntax equivalences in MySQL, PostgreSQL, and MongoDB, enabling you to transition seamlessly between these systems using their command-line interfaces (CLI).

Understanding the corresponding syntaxes in each database system facilitates code portability and collaboration among developers and administrators across different platforms.

Guide to Applying query on you mongodb atlas hosted database from command line

Introduction

Often when you're using a database in a dev project, you want to access it quickly to check for modifications. When you're working with mysql database, you have a client that can help you with that. But what to do when you're using mongo db ? In this tutorial, i present how to access, from command line, your databased hosted with mongo db atlas. Then i showcase basic still important query examples. It should work also for those hosted locally.

Prerequistes

  • Node js
  • a mongo db database, offline or locally served

Download and Install Mongosh

You can download and install mongosh from the MongoDB website or using package managers like npm or yarn. Make sure you have Node.js installed on your system before proceeding.

Personally, using windows, i've downloaded it (and installed the setup) from the website, put the bin file (containing mongosh.exe) into environment variables and read a bit of the docu. However, using ubuntu, i've tested both approch, installing using apt-get and using nodejs.

Let's use the Package Manage option, as it is a more straightforward approach

npx mongosh --version
yarn dlx mongosh --version