LoginSignup
14
9

More than 5 years have passed since last update.

mysql.slow_logテーブルからmysqldumpslowする

Posted at

CSVに変換

$ mysql -hホスト -uユーザー -pパスワード --batch -e "SELECT *
FROM mysql.slow_log
ORDER BY start_time DESC
LIMIT 100000" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > slow.csv

参考

CSVをFILE形式に変換

$ wget https://gist.github.com/yoku0825/3910570/raw/e104fe5ccd9eda172b01ba4007665bfa633db2b4/csv2slowlog.pl
$ chmod +x csv2slowlog.pl
$ ./csv2slowlog.pl slow.csv > slow.log

mysqldumpslow

$ mysqldumpslow -s t slow.log > dump.log
  • query_timeなどは復元できないみたい
14
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
9