Det er ikke rocket science, man det er rart at have ved hånden når man har brug for det 😉
mysql> tee /tmp/dump.log Logging to file '/tmp/dump.log' mysql> show processlist; +-------+----------+-----------+----------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-------+----------+-----------+----------+---------+------+-------+------------------+ | 11348 | ndoutils | localhost | ndoutils | Sleep | 0 | | NULL | | 11350 | root | localhost | NULL | Query | 0 | NULL | show processlist | +-------+----------+-----------+----------+---------+------+-------+------------------+ 2 rows in set (0.00 sec)
og:
root@nagios ~ # cat /tmp/dump.log mysql> show processlist; +-------+----------+-----------+----------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-------+----------+-----------+----------+---------+------+-------+------------------+ | 11348 | ndoutils | localhost | ndoutils | Sleep | 0 | | NULL | | 11350 | root | localhost | NULL | Query | 0 | NULL | show processlist | +-------+----------+-----------+----------+---------+------+-------+------------------+ 2 rows in set (0.00 sec) mysql> quit
😀
Hvis du er lidt glemsom og gerne vil have en reminder til hvilke queries du har fyret af:
# cat /root/.mysql_history tee /tmp/dump.log show processlist;
Hvis du har brug for et lidt mere struktureret udtræk, så er her et andet blogindlæg, “Save MySQL query results into a text or CSV file”! ( http://www.tech-recipes.com/rx/1475/save-mysql-query-results-into-a-text-or-csv-file/ )