The mysql command-line client supports a history (you can use the cursor-keys to access and navigate it), but is there a way to access it (for example) in bash?
In bash you can do:
history | grep "command"
Is there something similar in mysql?
On Unix, mysql writes the statements to a history file. By default, this file is named . mysql_history in your home directory.
The transaction log in MySQL is not enabled by default and must be enabled in order to log transactions. To determine if the transaction log is active you can use the “show binary logs” statement: SHOW BINARY LOGS; If binary logging is disabled you will receive an error stating “you are not using binary logging”.
Show activity on this post. From the bottom panel, change "Action Output" to "History" and then choose the appropriate date. Alternatively, the SQL statement history is stored in text files under two locations: sql_history/yyyy-mm-dd e.g., sql_history/2015-04-01: Full Workbench SQL history for all MySQL connections.
You may use Ctrl+R to search the history, as in bash.
Usually this lists up all MySQL commands that have been used:
less ~/.mysql_history
so, in mysql you can use:
system grep "command" ~/.mysql_history
Open the file in vim editor
vi ~/.mysql_history
then you can search the pattern with /
by entering you text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With