Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to Disable MySQL History  (Read 4826 times)

0 Members and 1 Guest are viewing this topic.

mohitht

  • Guest
How to Disable MySQL History
« on: December 30, 2013, 11:09:27 pm »
Hi All,


MySQL stores the commands typed in the mysql> prompt in the ~/.mysql_history file.

In order to view MySQL  history

# cat ~/.mysql_history


We can disable mysql history using MYSQL_HISTFILE environment variable

First, remove the ~/.mysql_history file

$ rm ~/.mysql_history

Set the MYSQL_HISTFILE env variable to /dev/null
$ export MYSQL_HISTFILE=/dev/null

$ set | grep MYSQL
MYSQL_HISTFILE=/dev/null



We can also disable mysql history by pointing .mysql_history to /dev/null

$ rm ~/.mysql_history


Create a symbolic link of ~/.mysql_history pointing to /dev/null as shown below.

$ ln -s /dev/null ~/.mysql_history

Now, login to the mysql and execute few sql commands. You’ll notice that ~/.mysql_history file is empty and does not store any previously typed commands.


Thanks :)