What is the mysql command to pass all command line input to a file on Fedora OS?

I am running multiple queries from mysql command line on my Linux box (Fedora Os). I would like to write it all down automatically to a file. I know Linux has a command called history and then you can pipe it to a file. Is there something like this for MYSQL. I would like to keep all my scripts and sql query just for reference at a later point.

Help rate.

0


source to share


2 answers


MySQL stores query history in a file ~/.mysql_history

. Certain characters are escaped in this file. The space becomes \040

; backslash becomes \\

. You can replace these escape sequences using sed

either your favorite text editor.



+1


source


Alternatively enable the mysql query log.

in /etc/mysql/my.cnf (or wherever you specify the OS), enter a section in config, for example:



[mysqld]
log=/var/log/mysql/mysqld.log

      

Then each request will be logged in this file.

0


source







All Articles