You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过MongoDB Compass连接本地C:MongoDB/data路径下的dataBase数据库?

Connecting to Your Local dataBase via MongoDB Compass

Hey there! Let me walk you through the straightforward steps to connect to your dataBase database stored at C:\MongoDB\data using MongoDB Compass. Here's what you need to do:

Step 1: Ensure MongoDB Service is Running

First things first — Compass connects to a running MongoDB instance, not directly to the disk files. So you need to start the MongoDB server pointing to your data directory:

  • Open a command prompt (CMD or PowerShell) as Administrator.
  • Run this command:
    mongod --dbpath "C:\MongoDB\data"
    
  • You’ll see logs indicating the server is running (look for a line like waiting for connections on port 27017). Leave this window open while using Compass.

Alternatively, if you’ve installed MongoDB as a Windows service, just start it via the Services app:

  • Press Win + R, type services.msc, and hit Enter.
  • Find the MongoDB service (usually named MongoDB), right-click it, and select Start.

Step 2: Open MongoDB Compass and Configure Connection

  • Launch MongoDB Compass. If it’s your first time, you’ll land directly on the connection screen. If not, click the New Connection button in the top-left corner.
  • For a default local setup, use the connection string:
    mongodb://localhost:27017/
    
    Or, fill in the fields manually:
    • Hostname: localhost
    • Port: 27017 (this is MongoDB’s default port; change it only if you configured a different one)

Step 3: Connect and Access Your dataBase

  • Click the Connect button. If the server is running correctly, you’ll see a list of all databases on your local instance.
  • Look for dataBase in the left-hand sidebar — click it to explore its collections, view documents, and perform any database operations you need.

Quick Troubleshooting Tips

  • If you get a "connection refused" error: Double-check that the MongoDB server is running and using the correct port.
  • If mongod throws a permission error: Make sure your user account has read/write access to C:\MongoDB\data.
  • If you don’t see dataBase listed: Confirm that the database actually exists (it’s created automatically when you first insert data, but if you haven’t done that yet, it won’t show up until you add collections/documents).

内容的提问来源于stack exchange,提问作者Dominik Domanski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:10:23