Skip to content

Instantly share code, notes, and snippets.

@johndhancock
Last active October 25, 2024 15:10
Show Gist options
  • Save johndhancock/e8d62fa653c210ec869e94db1da141f4 to your computer and use it in GitHub Desktop.
Save johndhancock/e8d62fa653c210ec869e94db1da141f4 to your computer and use it in GitHub Desktop.
Helpful MongoDB commands

Terminal

  • lsof -iTCP -sTCP:LISTEN -n -P: See what is running on which port
  • kill {portnumber}: Stop whatever is running on designated port
  • mongod --dbpath {dir_path}: Specify where mongodb should start up the database
  • mongosh: Enter the mongodb shell

Mongoshell

  • use {db_name}: Create a database by name
  • db.{collection_name}.insertMany({json_array}): Insert multiple records into a database collection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment