Properly initialize and finalize mysql library to reduce memleaks:
see: http://dev.mysql.com/doc/refman/5.0/en/c-api-function-overview.html
and: http://bugs.mysql.com/bug.php?id=7619
Fixed a huge memleak: mysql results were never freed...
See: http://dev.mysql.com/doc/refman/5.0/en/mysql-free-result.html