Forrest logo
back to the mongo tool

mongo:tldr:46d58

mongo: Connect to a database running on a given host on a given port.
$ mongo --host ${host} --port ${port} ${database}
try on your machine

This command is used to connect to a MongoDB database server using the MongoDB shell.

Here is a breakdown of the command components:

  • mongo: It is the command to start the MongoDB shell.

  • --host ${host}: This option specifies the host address where the MongoDB server is running. ${host} is a placeholder for the actual hostname or IP address of the server. This is where the shell will connect to.

  • --port ${port}: This option specifies the port number on which the MongoDB server is listening for connections. ${port} is a placeholder for the actual port number.

  • ${database}: This is a placeholder for the name of the database that you want to connect to. Replace it with the actual name of the database you want to use. If the database does not exist, a new one will be created.

By providing the appropriate values for ${host}, ${port}, and ${database}, you can connect to a specific MongoDB server and work with the specified database using the MongoDB shell.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mongo tool