Bug #80995 mysql_upgrade returns status code 2 if it determines it has already been run
Submitted: 7 Apr 2016 11:00 Modified: 7 Apr 2016 11:06
Reporter: Lars Tangvald Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.7.11 OS:Any
Assigned to: CPU Architecture:Any

[7 Apr 2016 11:00] Lars Tangvald
Description:
When running mysql_upgrade it will store a flag in datadir showing it's been run on that database. If run again it'll simply report that it has already been run. However this second run will return status code 2 instead of 0, which can cause scripts to interpret it as an error and fail.

2 is set as the value for ALREADY_UPGRADED, so this might be deliberate, but it's not documented.

How to repeat:
* Install MySQL server
* Run mysql_upgrade (possibly as root if user does not have write access to datadir)
* Run mysql_upgrade again
* Run echo $? to see the return value

Suggested fix:
Return 0 for ALREADY_UPGRADED, since it shouldn't be an error
[7 Apr 2016 11:06] MySQL Verification Team
Hello Lars,

Thank you for the report.

Thanks,
Umesh