≡ Menu

Clear MySQL command line query history

Question – I wish to clear the ~/.mysql_history file and want it to not keep the history recorded. Is there a way to do this?

MySQL stores all command line queries in a special file called ~/.mysql_history. This file is written by MySQL whenever you run a command line query using SSH or a local terminal.

To clear the query history, just remove the file:

rm -f ~/.mysql_history

This will clear your entire history of queries.

But this is not permanent. If you don’t want the history to be recorded ever again, you can create a symbolic link to /dev/null and the history will never be recorded.

rm -f ~/.mysql_history
ln -s /dev/null ~/.mysql_history

The second line (bolded) creates a symbolic link named .mysql_history to a special Linux file called /dev/null. Anything appended to the /dev/null file is discarded by the system immediately!

Incoming search terms:

  • how to delete existing ~/ mysql_history file (1)
  • how to delete mysql history in (1)

{ 0 comments… add one }

Leave a Comment