Bug #70544 mysql_upgrade should test if mysql data dir is writable before doing work
Submitted: 7 Oct 2013 17:25 Modified: 8 Oct 2013 15:32
Reporter: Justin Swanhart Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:all OS:Any
Assigned to: CPU Architecture:Any

[7 Oct 2013 17:25] Justin Swanhart
Description:
mysql_upgrade places a file in the data directory on successful completion.  This prevents mysql_upgrade from running more than once on the same version.  However, if the user running mysql_upgrade provides proper MYSQL credentials, but their OS user does not have write permissions into the DATADIR, then the database metadata in the `mysql` database will be upgraded, but the file will not be written, thus allowing mysql_upgrade to execute again on already updated metadata.

How to repeat:
run mysql_upgrade with a normal user that can not write into the data directory, but pass valid mysql credentials:
<mockup>
ec2-user$ /usr/local/mysql/bin/mysql_upgrade -u root -h127.0.0.1 -p
....
PERMISSION DENIED

Suggested fix:
Before doing any actual metadata upgrades, test that the user can write into the mysql datadir using a mysql_upgrade_start file.  You can immediately unlink it.
[8 Oct 2013 6:51] Shane Bester
seen http://bugs.mysql.com/bug.php?id=37169 ?
[8 Oct 2013 9:11] Umesh Shastry
Hello Justin,

Thank you for the report.
Verified as described.

It doesn't write upgrade info due to permission issue..
..
..
OK
Could not create the upgrade info file 'mysql_upgrade_info' in the MySQL Servers datadir, errno: 13

Thanks,
Umesh
[8 Oct 2013 15:32] Justin Swanhart
Sorry about the duplicate (that also seems to have many duplicates).  Obviously this issue needs to be looked at.  It is one of those long running annoyances like the difference between 127.0.0.1 and localhost.