/usr/share/doc/dbconfig-common/examples/db-test-mysql-perl-2.0/mysql-install.pl is in dbconfig-common 1.8.47+nmu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #!/usr/bin/perl
use DBI;
use strict;
# this is the value of the config file passed to us by dbconfig-common
my $conffile = $ENV{'dbc_config_include'};
# these are the default names of the variables in the config file
our ($dbname, $dbuser, $dbpass, $dbserver, $dbtype);
# load 'er up.
require $conffile;
my $dsn = "DBI:$dbtype:database=$dbname;host=$dbserver";
# error checking here would be a plus.
my $dbh = DBI->connect($dsn, $dbuser, $dbpass);
# error checking here would be a plus too.
$dbh->do("CREATE TABLE IF NOT EXISTS versiontable ( version varchar(32) PRIMARY KEY NOT NULL )");
$dbh->do("DELETE FROM versiontable");
$dbh->do("INSERT INTO versiontable VALUES ( '2.1' )");
$dbh->disconnect();
exit 0;
|