Digital Marketing

Check MySQL query history from command line

The .mysql_history file is internally used by the command line editiing utility program, called libedit. The file is not intended to be directly viewed, or edited etc.

The content of the file is encoded by wctomb. To view the content:

shell> cat ~/.mysql_history | python2.7 -c "import sys; print(''.join([l.decode('unicode-escape') for l in sys.stdin]))"

If your system has python 3.x installed, the command must be changed like below:

shell> cat ~/.mysql_history | python -c "import sys; print(*[l.decode('unicode-escape') for l in sys.stdin.buffer])"

MyCli History and Search
MyCli keeps track of the queries entered in the repl. Up/Down arrow can be used to navigate the history.

Pressing <C-r> will enable incremental history search. So press <C-r> and then start typing your search term to see the queries narrowed down. You can cycle through the matches by pressing <C-r> again.

The history file ~/.mycli-history contains all the sql statements and the timestamp that you have executed.


Popular posts from this blog

Make online money from the Internet