DBI has excellent function DBI->trace(2), printing a string for each DBI action made (as connect, prepare, execure). Will even show you which data were fetched, row by row. Excellent for debug.
Originally posted as a Categorized Answer.
Comment on Re: How can I see error messages from MySQL?