MongoDB 有 shell 历史文件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5751694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does MongoDB have a shell history file?
提问by ma11hew28
Does MongoDB have something like a .bash_history
file?
MongoDB 有类似.bash_history
文件的东西吗?
I recently typed in a long command, closed & re-opened the shell, and want to retrieve it.
我最近输入了一个很长的命令,关闭并重新打开外壳,并想检索它。
Pressing up doesn't work as it seems that the history of the last shell is not accessible in the new shell.
向上按不起作用,因为在新 shell 中似乎无法访问最后一个 shell 的历史记录。
I installed 1.8.1 with Homebrew. Is there a configuration variable I should set that will turn on MongoDB interactive shell history logging?
我用 Homebrew 安装了 1.8.1。是否有我应该设置的配置变量来打开 MongoDB 交互式 shell 历史记录?
Here's my mongod.conf
file:
这是我的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
回答by lobster1234
Yes, its in ~/.dbshell
as of version 1.8.1 which I am using. But this could be something they added in 1.7+ as from what I recall 1.6.5 does not have it.
是的,它在~/.dbshell
我使用的版本 1.8.1 中。但这可能是他们在 1.7+ 中添加的东西,因为我记得 1.6.5 没有它。
回答by HISI
of course yes,
当然是的
it's in your home Path : ~/.dbshell
like lobster1234 said.
for windows you should check out the link https://docs.mongodb.com/manual/reference/program/mongo/#files
它在你的家路径中:~/.dbshell
就像 lobster1234 说的。对于 Windows,您应该查看链接https://docs.mongodb.com/manual/reference/program/mongo/#files
but beware, you should save the contents in other file (cat .dbshell >>Mongohistory.txt)
after you have used mongo shell, becouse mongodb shell don't ganna save the whole commandes that you have taped in.
但请注意,在(cat .dbshell >>Mongohistory.txt)
使用 mongo shell 后,您应该将内容保存在其他文件中,因为 mongodb shell 不会保存您录制的整个命令。
回答by Aza
For windows, type the following in the powershell:
对于 Windows,请在 powershell 中键入以下内容:
$ cat ~/.dbshell
回答by gil.fernandes
On Windows cmd
you can type this command to see the history:
在 Windows 上,cmd
您可以键入以下命令来查看历史记录:
notepad %userprofile%\.dbshell
If you have VS code installed, this also works:
如果您安装了 VS 代码,这也适用:
code %userprofile%\.dbshell