如何从mongo shell中为Mongo(v2.2.0)指定修复路径?
例如,我通常可以运行命令:
mongod --repair --repairpath /opt/vol2/data
如果我在shell中使用以下语法,我如何指定修复路径:
db.repairDatabase()
答案 0 :(得分:0)
repairDatabase
命令将在您当前连接到的数据库上执行,并通过扩展名在当前数据库的数据所在的路径上执行。
您可以使用mongo shell中的use [dbname]
命令定义要使用的数据库:
取自the docs:
use <db>
将当前数据库切换到<db>
。 mongo shell变量 db设置为当前数据库。
或者,您可以在starting the actual shell时指定要使用的数据库。例如,如果要连接到端口27016上运行的my_db
数据库上的shell,则可以使用以下命令启动mongo shell:
$ mongo my_db
要找出您当前使用的数据库,只需在shell中键入db
,即可获得当前数据库的名称。