MySQL I : Logging

1. Error logging is enabled by default. With a text editor, examine the file “c:\mysql\data\mysql.err”
2. To enable update tracking, stop the MySQL service or daemon.
– Open Start > Settings > Control Panel > Administrative Tools > Services
– Stop the MySQL service
– Double click the MySQL service to open its properties.
– Click “Stop” to stop the service.
– Find the “Start Parameters” field, and type: –log-update
– Restart the service.
– Update logging is stored in the /data directory, and named <hostname>.00n, where n corresponds to the last log number.

– There are many different ways to do this on Linux, often which are distribution dependant. It’s probably best to look at you /etc/rc.d/init.d/mysql script to see how it is being started up, and either add the –log-update argument there, or elsewhere if the script is starting MySQL in some other way.

3. To see a change in the transaction log, enter the MySQL client:
mysql –u root –p
USE accounting;
INSERT INTO expense_categories VALUES (NULL, ‘Employee Benefits’);

Look at the log with a text editor, for example: localhost.001. You should see the update you just performed.
4. Note that the reason that update logging is not enabled by default is that it slows down database performance, sometimes considerably.
5. Note that update logs quickly can grow large. If your disk is filling up and you don’t know why, always suspect your logs.
6. Archiving your logs is a good idea. Why?
7. UNIX shell commands (like “tail” and “grep”) are very handy for looking at parts of large logs. These are available on UNIX/Linux or on Windows if you have the CYGWIN toolkit installed.