mongoimport --db test --collection collection1 --file c:/test.json
执行上述命令时出现 SyntaxError: Unexpected identifier。
这个脚本有什么问题?
非常感谢
mongoimport --db test --collection collection1 --file c:/test.json
执行上述命令时出现 SyntaxError: Unexpected identifier。
这个脚本有什么问题?
非常感谢
当我尝试从 MongoDB Shell 导入 json 文件时,我遇到了同样的问题。
您可以从命令提示符查询它。
我的目录结构:
C:\Program files\MongoDB\Server\3.0\bin\mongoimport.exe
C:\filename.json
例如
C:\Program Files\MongoDB\Server\3.0\bin> ./mongoimport --db dbname --collection collection_name C:\filename.json
输出应该是:
2015-08-18T09:34:25.617-0700 connected to: localhost
2015-08-18T09:34:25.632-0700 imported 10 documents
现在切换回 MongoDB Shell:
C:\Program Files\MongoDB\Server\3.0\bin> ./mongo
use dbname
db.collection_name.find().pretty()
这里的一个问题可能是您没有在计算机上正确设置 PATH。如果您使用的是 Windows 10 -