• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
Big Data | Install and configure MongoDB (4.2)
  1. References
  2. Install MongoDB
  3. Start MongoDB
  4. Uninstall MongoDB
  5. How to create users in MongoDB?
  6. MongoDB "admin" database
  7. How to use collections?
  8. Some common "mongo" commands
  9. How to execute "mongo" commands from Linux shell?
  10. How to allow remote connections to MongoDB?
  11. Cannot install MongoDB on Ubuntu?

  1. References
    See this page for more details on how to install MongoDB:
    https://docs.mongodb.com/manual/installation/
  2. Install MongoDB

    Enable mongod server service:

    Check installation:

    Configuration files:
    • Binary file: /usr/bin/mongod

    • Configuration file: /etc/mongod.conf

    • DB path: /var/lib/mongodb/

    • Log file: /var/log/mongodb/mongod.log
  3. Start MongoDB
    Start MongoDB as a service:
    Start MongoDB as a process using "config" paramter:
    Start MongoDB as a process using "dbpath" paramter:
    Verify MongoDB status:
    Verify MongoDB process:
    List active connections:

    Stop MongoDB:
  4. Uninstall MongoDB
    Uninstall MongoDB:
  5. How to create users in MongoDB?
    Create a user/password on a specific database:
    If you don't connect to a specific database, the user will be created on the "test" database:
    Create the user:
    Verify user creation:
    Test user connection:
    List all users of a database:
    Delete a user:
  6. MongoDB "admin" database




  7. How to use collections?





  8. Some common "mongo" commands











  9. How to execute "mongo" commands from Linux shell?
    List databases:
    List collections names of a specific database:
  10. How to allow remote connections to MongoDB?
    Configuration file: /etc/mongod.conf
    Test connection:
  11. Cannot install MongoDB on Ubuntu?
    Remove mongodb-org package: Uninstall MongoDB

    Remove the existing mongodb.list:

    Create the MongoDB repository list file:

    If you execute the command "apt update" you might get the following error:

    So first, you need to add the MongoDB key:

    Install MongoDB:

    You can find the MongoDB puclic key ("4B7C549A058F8B6B") by visiting the Ubuntu key server http://keyserver.ubuntu.com
    • Enter the "OpenPGPkeyserver": MongoDB
    • Click "Search Key".
    • In the search result page, find the version "4.2" and look for the last up-to-date key.
© 2025  mtitek