Reputation: 306
Is there a command to clear the history from within the mongo shell?
Upvotes: 16
Views: 10878
Reputation: 55
Run:
sudo rm ~/.mongodb/mongosh/mongosh_repl_history
Once that's done, all of your history will have been deleted from the MongoDB Shell.
Upvotes: 1
Reputation: 330
If you're using MongoDB Shell as a standalone package, you will find the shell history file located in ~/.dbshell
If you're using the embedded MongoDB Shell inside MongoDB Compass, you will find the shell history file located in ~/.config/MongoDB Compass/MongoDB Compass/shell-history.json
Just empty the history file
Upvotes: 0
Reputation: 17408
Command history is stored in ~/.dbshell file.
For example, on a Unix-like system:
# Ensure an empty history file
echo "" > ~/.dbshell
# Remove rwx access to the history file
chmod 0 ~/.dbshell
Upvotes: 0
Reputation: 92745
MongoDB terminal history is stored inside the ~/.dbshell
file. Just empty the .dbshell
file
$ > ~/.dbshell
Versions of Windows mongo.exe earlier than 2.2.0 will save the .dbshell file in the mongo.exe working directory.
Upvotes: 5
Reputation: 4359
There should be a file called .dbshell in your home folder. Just delete it.
Upvotes: 37