grousso

Log every SQL query to a log file really easily

Jul 3rd, 2019
322
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. You can log every query to a log file really easily:
  2.  
  3. mysql> SHOW VARIABLES LIKE "general_log%";
  4.  
  5. +------------------+----------------------------+
  6. | Variable_name | Value |
  7. +------------------+----------------------------+
  8. | general_log | OFF |
  9. | general_log_file | /var/run/mysqld/mysqld.log |
  10. +------------------+----------------------------+
  11.  
  12. mysql> SET GLOBAL general_log = 'ON';
  13. Do your queries (on any db). Grep or otherwise examine /var/run/mysqld/mysqld.log
  14.  
  15. Then don't forget to
  16.  
  17. mysql> SET GLOBAL general_log = 'OFF';
  18.  
  19.  
  20. or the performance will plummet and your disk will fill!
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment