Reputation: 15599
I run several queries from mysql command line on my linux box (Fedora Os). I would like to capture all these automatically to a file. I know there is command in Linux called history and then you can pipe it to a file. Is there anything similar for MYSQL. I would like to save all my scripts and sql query just for reference sake at a later point in time.
Help Appreciated.
Upvotes: 1
Views: 1369
Reputation: 7168
Alternatively, turn on the mysql query log.
in your /etc/mysql/my.cnf file (or wherever your OS puts it), put a section in the config like:
[mysqld]
log=/var/log/mysql/mysqld.log
Then, every query will be logged to this file.
Upvotes: 0
Reputation: 137196
MySQL stores your query history in the file ~/.mysql_history
. Certain characters are escaped in this file. Space becomes \040
; backslash becomes \\
. You can replace these escape sequences using sed
or your favorite text editor.
Upvotes: 1