Perl DBD::mysql Administrative Functions

MySQL LogoI was flipping through O’Reilly’s High Performance MySQL and noticed something handy on page 519 … $dbh->func(‘shutdown’,’admin’);

You can call 4 mysql_* C API functions from within Perl scripts using DBD::mysql, that are also exposed in mysqladmin:

$ perldoc DBD::mysql
$rc = $dbh->func('shutdown','admin');
$rc = $dbh->func('reload','admin');
$rc = $dbh->func('createdb',$database,'admin');
$rc = $dbh->func('dropdb',$database,'admin');

So you don’t need to shell out and call mysqladmin to shutdown a MySQL server.

Also nice, it would be trivial to add additional admin functions using the existing framework in DBD::mysql.

One example might be adding the status command, available to mysqladmin and the mysql command line client.

This entry was posted in MySQL, Open Source, Perl, Tech, Toys. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.