--- /usr/bin/mysqld_multi.orig 2018-03-09 18:37:19.025626239 +0000 +++ /usr/bin/mysqld_multi 2018-03-09 17:55:40.000000000 +0000 @@ -20,9 +20,10 @@ use Getopt::Long; use POSIX qw(strftime getcwd); use File::Path qw(mkpath); +use File::Basename; $|=1; -$VER="2.16"; +$VER="2.16-dev"; my @defaults_options; # Leading --no-defaults, --defaults-file, etc. @@ -323,12 +324,39 @@ { @options = defaults_for_group($groups[$i]); + $system_user = 'mysql'; # set default system user to 'mysql' + for ($j = 0, $tmp= ""; defined($options[$j]); $j++) + { + if ("--user=" eq substr($options[$j], 0, 7)) { + $system_user = $options[$j]; + $system_user =~ s/\-\-user\=//; + } + } + $basedir_found= 0; # The default $mysqld_found= 1; # The default $mysqld_found= 0 if (!length($mysqld)); $com= "$mysqld"; for ($j = 0, $tmp= ""; defined($options[$j]); $j++) { + if ("--socket=" eq substr($options[$j], 0, 9)) { + $socket = $options[$j]; + $socket =~ s/\-\-socket\=//; + $socket_dir = dirname($socket); + if (! -d $socket_dir) { + eval { mkpath($socket_dir, { user => $system_user }) }; + } + } + if ("--pid-file=" eq substr($options[$j], 0, 11)) { + $pidfile = $options[$j]; + $pidfile =~ s/\-\-pid-file\=//; + $pidfile_dir = dirname($pidfile); + if (! -d $pidfile_dir) { + eval { mkpath($pidfile_dir, { user => $system_user }) }; + } + } + + if ("--datadir=" eq substr($options[$j], 0, 10)) { $datadir = $options[$j]; $datadir =~ s/\-\-datadir\=//; @@ -341,7 +369,7 @@ if (-w $datadir) { print "\n\nInstalling new database in $datadir\n\n"; $install_cmd="/usr/local/Percona-Server-5.7.19-17-Linux.x86_64.ssl101/bin/mysql_install_db "; - $install_cmd.="--user=mysql "; + $install_cmd.="--user=$system_user "; $install_cmd.="--datadir=$datadir"; system($install_cmd); } else {