MongoDB有shell历史文件吗?

问题描述 投票:32回答:3

MongoDB有类似.bash_history文件的东西吗?

我最近键入了一个长命令,关闭并重新打开shell,并想要检索它。

按下按钮不起作用,因为似乎在新shell中无法访问最后一个shell的历史记录。

我用Homebrew安装了1.8.1。我应该设置一个配置变量来打开MongoDB交互式shell历史记录吗?

这是我的mongod.conf文件:

# Store data in /usr/local/var/mongodb instead of the default /data/db
dbpath = /usr/local/var/mongodb

# Only accept local connections
bind_ip = 127.0.0.1
# Enable Write Ahead Logging (not enabled by default in production deployments)
journal = true
mongodb history interactive-shell
3个回答
38
投票

是的,它在我使用的1.8.1版本的~/.dbshell中。但这可能是他们在1.7+中添加的东西,因为我记得1.6.5没有它。


1
投票

当然是的,

它在你家的路径:~/.dbshell像龙虾1234说。对于Windows,你应该看看链接https://docs.mongodb.com/manual/reference/program/mongo/#files

但要注意,你应该在使用mongo shell之后将内容保存在其他文件(cat .dbshell >>Mongohistory.txt)中,因为mongodb shell不会ganna保存你录制的整个commandes。


0
投票

对于Windows,在powershell中键入以下内容:

$ cat ~/.dbshell
© www.soinside.com 2019 - 2024. All rights reserved.