我正在尝试将一个MongoDB数据库转储到一个归档文件中。使用文档中给出的以下命令。
sudo mongodump --uri=mongodb://username:password@host:27017/dbname?authMechanism=SCRAM-SHA-1&authSource=authdb --archive=file.archive但是它并不像预期的那样转储,而是为每个.json文件创建一个包含collection文件的转储文件夹,这应该是一个给定的归档文件。
它还显示了以下错误-
--archive=file.archive: command not found
蒙戈版-
MongoDB shell version v3.6.3发布于 2022-07-26 06:24:56
我遇到了这个问题&我想出了事情发生的原因。
我当时运行的命令是
sudo /usr/bin/mongodump --uri=mongodb+srv://{username}:{password}@{atlasendpoint}.mongodb.net/?retryWrites=true&w=majority --archive={filename}.archive --gzip 2>&1我和你犯了同样的错误。我通过将引号包装在URL上来更改shell命令;这个命令为我修复了它。
sudo /usr/bin/mongodump --uri="mongodb+srv://{username}:{password}@{atlasendpoint}.mongodb.net/?retryWrites=true&w=majority" --archive={filename}.archive --gzip 2>&1https://stackoverflow.com/questions/62598024
复制相似问题