When I run the mongo client, it stores a history of commands in $HOME/.dbshell. I would prefer not to log any commands from Mongo.
How do I disable the behavior that writes to the .dbshell file? I don't want to write it to /tmp, I want to avoid having it write anywhere.
This page does not provide useful information here.
MongoDB Shell ( mongo ) The MongoDB Shell is located in the same place as the other binaries. So to run it, open a new Terminal/Command Prompt window and enter mongo (Linux/Mac) or mongo.exe (Windows). This assumes that the path has been added to your PATH. If it hasn't, you'll need to provide the full path.
The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mongo shell to query and update data as well as perform administrative operations.
As at MongoDB 3.4, there is no explicit option to disable the mongo
shell history feature.
A possible workaround is to make the history file read-only. The mongo
shell will currently continue without error if the .dbshell
file cannot be read or written.
For example, on a Unix-like system:
# Ensure an empty history file
echo "" > ~/.dbshell
# Remove rwx access to the history file
chmod 0 ~/.dbshell
I've raised a feature suggestion for this in the MongoDB issue tracker which you can watch, upvote, or comment on: SERVER-29103: Add option to disable writing shell history to .dbshell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With