[Rt-devel] RT 3.4.2 + MySQL and a database name like "rtdb-service"
Laurent GAUTROT
laurent.gautrot at equipement.gouv.fr
Mon Jul 18 02:17:40 EDT 2005
While installing RT 3.4.2 + MySQL, I specified a database with a custom
databasename, something like 'rtdb-servicename'. The problem was caused by
the
hyphen in the database name.
I had troubles for rt-setup-database, the script just died. Here is a patch I
applied to get the database created with the ACL.
The point is the protection of the MySQL database name and the protection of
the MySQL database username with "`".
diff -ru rt-3.4.2/etc/acl.mysql rt-3.4.2-lg/etc/acl.mysql
--- rt-3.4.2/etc/acl.mysql 2004-06-26 22:31:56.000000000 +0200 +++
rt-3.4.2-lg/etc/acl.mysql 2005-06-17 17:39:09.000000000 +0200 @@ -4,6
+4,6 @@
"USE mysql;",
"DELETE FROM user WHERE user = '${RT::DatabaseUser}';",
"DELETE FROM db where db = '${RT::DatabaseName}';",
-"GRANT SELECT,INSERT,CREATE,INDEX,UPDATE,DELETE ON ${RT::DatabaseName}.* TO
${RT::DatabaseUser}\@'${RT::DatabaseRTHost}' IDENTIFIED BY
'${RT::DatabasePassword}';");
+"GRANT SELECT,INSERT,CREATE,INDEX,UPDATE,DELETE ON
`${RT::DatabaseName}`.* TO
${RT::DatabaseUser}\@'${RT::DatabaseRTHost}' IDENTIFIED BY
'${RT::DatabasePassword}';");
}
1;
diff -ru rt-3.4.2/sbin/rt-setup-database.in
rt-3.4.2-lg/sbin/rt-setup-database.in
--- rt-3.4.2/sbin/rt-setup-database.in 2005-02-01 15:20:40.000000000 +0100
+++ rt-3.4.2-lg/sbin/rt-setup-database.in 2005-07-07
22:10:12.000000000
+0200
@@ -246,6 +246,10 @@
unlink $RT::DatabaseName or warn $!;
return;
}
+ if ( $RT::DatabaseType eq 'mysql' ) {
+ $dbh->do("Drop DATABASE `$RT::DatabaseName`") or warn
$DBI::errstr;
+ return;
+ }
$dbh->do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr;
}
@@ -270,6 +274,9 @@
$ENV{DB_LOCALE} = 'en_us.utf8';
$dbh->do("CREATE DATABASE $RT::DatabaseName WITH BUFFERED LOG");
}
+ elsif ( $RT::DatabaseType eq 'mysql' ) {
+ $dbh->do("CREATE DATABASE `$RT::DatabaseName`");
+ }
else {
$dbh->do("CREATE DATABASE $RT::DatabaseName") or die
$DBI::errstr;
}
More information about the Rt-devel
mailing list