MongoDB有shell历史文件吗?

时间:2011-04-22 02:20:52

标签: mongodb history interactive-shell

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

4 个答案:

答案 0 :(得分:40)

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

答案 1 :(得分:1)

当然是的,

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

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

答案 2 :(得分:0)

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

$ cat ~/.dbshell

答案 3 :(得分:0)

在Windows cmd上,您可以键入以下命令以查看历史记录:

notepad %userprofile%\.dbshell

如果您已安装VS代码,则此方法也适用:

code %userprofile%\.dbshell