How to search mysql command history

The mysql command line client supports history (you can use the cursor keys to access and navigate it), but is there a way to search for a string, how can you do (for example) bash?

In bash you can:

history | grep "command" 

Is there something similar in mysql?

+6
source share
4 answers

This usually lists all the MySQL commands used:

 less ~/.mysql_history 
+6
source

You can use Ctrl + R to search for history, as in bash.

+8
source

so in mysql you can use:

grep system "command" ~ / .mysql_history

+3
source

Open the file in vim editor

vi ~/.mysql_history

then you can search for a pattern with / by entering text.

0
source

Source: https://habr.com/ru/post/978982/


All Articles