how to set mongod --dbpath

前端 未结 12 1698
囚心锁ツ
囚心锁ツ 2020-12-29 19:50

very new to mongodb and databases in general. whenever i run mongo i receive this error message: ​​​

MongoDB shell version: 2.         


        
相关标签:
12条回答
  • 2020-12-29 20:21

    Windows environment, local machine. I had an error

    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: 
    Error connecting to 127.0.0.1:27017 :: caused by :: 
    No connection could be made because the target machine actively refused it. :
    

    After some back and forth attempts I decided

    • to check Windows "Task Manager". I noticed that MongoDB process is stopped.
    • I made it run. Everything starts working as expected.
    0 讨论(0)
  • 2020-12-29 20:24

    Have only tried this on Mac:

    • Create a data directory in the root folder of your app
    • cd into your wherever you placed your mongo directory when you installed it
    • run this command:

      mongod --dbpath ~/path/to/your/app/data

    You should be good to go!

    0 讨论(0)
  • 2020-12-29 20:25

    You can use --dbpath flag in order to provide it with the parameters i.e, the directory address. I found it useful for Windows 10 OS.

    With the default settings it is usually not required.

    0 讨论(0)
  • 2020-12-29 20:27

    Create a directory db in home, inside db another directory data

    cd 
    mkdir db
    cd db
    mkdir data
    

    then type this command--

    mongod --dbpath ~/db/data
    
    0 讨论(0)
  • 2020-12-29 20:29

    For me it must have:

    mongod --dbpath=/whatever/data/path
    
    0 讨论(0)
  • 2020-12-29 20:29
    sudo mongod --dbpath ~/data
    

    This made it work for me.

    0 讨论(0)
提交回复
热议问题