Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the mongo .dbshell history file

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.

like image 456
Kevin Burke Avatar asked May 06 '17 05:05

Kevin Burke


People also ask

Where is mongo shell located?

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.

What does it do in mongo shell?

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.


1 Answers

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.

like image 61
Stennie Avatar answered Sep 17 '22 13:09

Stennie