Quantcast
Channel: Linux Report » Linux Quick Tips
Viewing all articles
Browse latest Browse all 30

Log MySQL Queries

$
0
0

If you want to log MySQL Queries log in to your mysql client and run:

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------+
| Variable_name    | Value                 |
+------------------+-----------------------+
| general_log      | ON                    |
| general_log_file | /var/db/mysql/machine.log |
+------------------+-----------------------+
2 rows in set (0.00 sec)
 
mysql>
mysql>
mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.00 sec)

Then to see the queries as soon as they run do tail on the log.

tail -f /var/db/mysql/machine.log

After you’ve seen the queries and you’ve completed the debug task it is a good practice do disable logging:

mysql> SET GLOBAL general_log = 'OFF';
Query OK, 0 rows affected (0.02 sec)

Viewing all articles
Browse latest Browse all 30

Latest Images

Trending Articles





Latest Images