Bug #77878 RPM scripts fail with multiple datadir=
Submitted: 30 Jul 2015 4:34 Modified: 27 Aug 2015 13:45
Reporter: Andrew Dalgleish Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:5.6 OS:Linux
Assigned to: CPU Architecture:Any

[30 Jul 2015 4:34] Andrew Dalgleish
Description:
If the configuration files contain more than one datadir= line,
the scripts fail with a misleading error message.

rpm -Uvh MySQL-server-advanced-5.6.25-1.rhel5.x86_64.rpm
Preparing...                ########################################### [100%]
/var/tmp/rpm-tmp.36304: line 115: [: /path/to/datadir: binary operator expected
You have more than one PID file:
ls: /path/to/datadir/*.pid: No such file or directory
drwxr-xr-x 35 mysql mysql 4096 Jul 28 09:15 /path/to/datadir
Please check which one (if any) corresponds to a running server
and delete all others before repeating the MySQL upgrade.

How to repeat:
Edit my.cnf and add two datadir= lines (either the same or different).

Install the server rpm.

Suggested fix:
Change this line:

mysql_datadir=`/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`

to

mysql_datadir=`/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | tail -n 1 | sed -n 's/--datadir=//p'`
[30 Jul 2015 4:40] MySQL Verification Team
The "binary operator expected" error comes from these two lines:

STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER

if [ -f $STATUS_FILE ]; then
[27 Aug 2015 13:45] Paul DuBois
Noted in 5.5.46, 5.6.27, 5.7.9, 5.8.0 changelogs.

RPM installation scripts if configuration files contained multiple
datadir lines. Now the last datadir line is used.
[17 Dec 2015 14:04] Paul DuBois
There was a missing word in the changelog entry, which should be:

RPM installation scripts failed if configuration files contained
multiple datadir lines. Now the last datadir line is used.