Location of the mongodb database on mac

后端 未结 6 1214
离开以前
离开以前 2021-01-29 17:37

I am kind of new to mac as well as mongodb.

I have a weird doubt, accessing the database created using mongodb on mac?

I know, in windows there is a folder calle

相关标签:
6条回答
  • 2021-01-29 18:05

    The default data directory for MongoDB is /data/db.

    This can be overridden by a dbpath option specified on the command line or in a configuration file.

    If you install MongoDB via a package manager such as Homebrew or MacPorts these installs typically create a default data directory other than /data/db and set the dbpath in a configuration file.

    If a dbpath was provided to mongod on startup you can check the value in the mongo shell:

    db.serverCmdLineOpts()
    

    You would see a value like:

    "parsed" : {
        "dbpath" : "/usr/local/data"
    },
    
    0 讨论(0)
  • 2021-01-29 18:08

    Thanks @Mark, I keep forgetting this again and again. After installing MongoDB with Homebrew:

    • The databases are stored in the /usr/local/var/mongodb/ directory
    • The mongod.conf file is here: /usr/local/etc/mongod.conf
    • The mongo logs can be found at /usr/local/var/log/mongodb/
    • The mongo binaries are here: /usr/local/Cellar/mongodb/[version]/bin
    0 讨论(0)
  • 2021-01-29 18:10

    I have just installed mongodb 3.4 with homebrew.(brew install mongodb) It looks for /data/db by default.

    https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

    0 讨论(0)
  • 2021-01-29 18:12

    Env: macOS Mojave 10.14.4

    Install: homebrew

    Location:/usr/local/Cellar/mongodb/4.0.3_1

    Note :If update version by brew upgrade mongo,the folder 4.0.4_1 will be removed and replace with the new version folder

    0 讨论(0)
  • 2021-01-29 18:16

    If mongodb is installed via Homebrew the default location is:

    /usr/local/var/mongodb

    See the answer from @simonbogarde for the location of other interesting files that are different when using Homebrew.

    0 讨论(0)
  • 2021-01-29 18:17

    I had the same problem, with version 3.4.2

    to run it (if you installed it with homebrew) run the process like this:

    $ mongod --dbpath /usr/local/var/mongodb
    
    0 讨论(0)
提交回复
热议问题