Cannot import mongodb

后端 未结 7 1210
余生分开走
余生分开走 2020-12-03 14:36

I tried mongo import like this

  1. mongoimport -d test -c foo importfile.json
  2. mongoimport --host localhost --db local --collection lec
相关标签:
7条回答
  • 2020-12-03 14:38

    One solution is:

    First, in cmd, change to the directory containing mongoexport.exe file, then type your command.

    C:\Program Files\MongoDB\Server\3.2\bin> .\mongoexport.exe -d foo -c bar -o output.json
    
    0 讨论(0)
  • 2020-12-03 14:40

    Open a new terminal or command prompt within the location of the file you want to import and it should work. It will not work on MongoDB shell

    0 讨论(0)
  • 2020-12-03 14:41

    mongoimport is to be run on the terminal and not inside the mongo shell. To run mongoimport in terminal, you will need to install the same. On ubuntu, you can do : apt-get install mongo-tools Hope this helps :)

    0 讨论(0)
  • 2020-12-03 14:42

    I had the same problem and was able to figure it out after a brief struggling and googling. 1. Navigate to the bin directory in command prompt (cd c:..\bin) 2. Run the mongoimport command but you have to specify the full path of your json file. That solves the problem

    0 讨论(0)
  • 2020-12-03 14:54

    try to use CSV is a good.

    mongoimport -d mydb -c things --type csv --file locations.csv --headerline --upsert
    

    You can convert by ms excel.

    0 讨论(0)
  • 2020-12-03 14:58

    mongoimport is intended to run in command prompt and not in the mongo shell. Try exiting out of the shell and running the command.

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