Bug #45415 rpm upgrade recreates test database
Submitted: 9 Jun 2009 20:17 Modified: 22 Jul 2011 18:44
Reporter: Harrison Fisk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:5.1.34, 5.0+ OS:Linux (Red Hat/SUSE)
Assigned to: Joerg Bruehe CPU Architecture:Any
Triage: Triaged: D4 (Minor)

[9 Jun 2009 20:17] Harrison Fisk
Description:
When you use rpm to upgrade your MySQL installation, you will end up getting the 'test' database recreated.  The reason is that the installation script in %pre does a mkdir on the datadir, datadir/mysql, and datadir/test no matter what.

It also re-runs the mysql_install_db script which will recreate the test database as well.

How to repeat:
1.  Install MySQL via RPM package.
2.  Drop the 'test' database.
3.  Upgrade the MySQL installation via RPM.
4.  Verify that the test database is back.

Suggested fix:
The logic exists in %pre to check for a previous installation.  Only run the mysql_install_db and directory creation if it wasn't already installed.
[7 Jul 2011 15:56] Joerg Bruehe
The fix is as proposed in the original report:
Both the "mkdir" for the "test" directory and the call to "mysql_install_db" will be done only in the case of an upgrade, not of a new installation.

The patch is committed, got approved by Jonathan Perkin via IRC.

The patch is pushed to the sources, for 5.1, 5.5, and 5.6.
(5.0 is unchanged.)
[22 Jul 2011 18:44] Paul Dubois
Noted in 5.1.59, 5.5.16, 5.6.3 changelogs.

Upgrades using an RPM package recreated the test database, which is 
undesirable when the DBA had removed it.