diff --git a/mysql/lib/x86_64-linux-gnu/libaio.so.1 b/mysql/lib/x86_64-linux-gnu/libaio.so.1 new file mode 100644 index 00000000..189e0ac5 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libaio.so.1 differ diff --git a/mysql/lib/x86_64-linux-gnu/libc.so.6 b/mysql/lib/x86_64-linux-gnu/libc.so.6 new file mode 100644 index 00000000..db27b090 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libc.so.6 differ diff --git a/mysql/lib/x86_64-linux-gnu/libcrypto.so.3 b/mysql/lib/x86_64-linux-gnu/libcrypto.so.3 new file mode 100644 index 00000000..7bb0ef6c Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libcrypto.so.3 differ diff --git a/mysql/lib/x86_64-linux-gnu/libevent_core-2.1.so.7 b/mysql/lib/x86_64-linux-gnu/libevent_core-2.1.so.7 new file mode 100644 index 00000000..413be934 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libevent_core-2.1.so.7 differ diff --git a/mysql/lib/x86_64-linux-gnu/libevent_pthreads-2.1.so.7 b/mysql/lib/x86_64-linux-gnu/libevent_pthreads-2.1.so.7 new file mode 100644 index 00000000..e82457f0 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libevent_pthreads-2.1.so.7 differ diff --git a/mysql/lib/x86_64-linux-gnu/libgcc_s.so.1 b/mysql/lib/x86_64-linux-gnu/libgcc_s.so.1 new file mode 100644 index 00000000..f078db35 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libgcc_s.so.1 differ diff --git a/mysql/lib/x86_64-linux-gnu/libicudata.so.70 b/mysql/lib/x86_64-linux-gnu/libicudata.so.70 new file mode 100644 index 00000000..b09a7fe1 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libicudata.so.70 differ diff --git a/mysql/lib/x86_64-linux-gnu/libicui18n.so.70 b/mysql/lib/x86_64-linux-gnu/libicui18n.so.70 new file mode 100644 index 00000000..851a5265 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libicui18n.so.70 differ diff --git a/mysql/lib/x86_64-linux-gnu/libicuuc.so.70 b/mysql/lib/x86_64-linux-gnu/libicuuc.so.70 new file mode 100644 index 00000000..9ebcd387 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libicuuc.so.70 differ diff --git a/mysql/lib/x86_64-linux-gnu/liblz4.so.1 b/mysql/lib/x86_64-linux-gnu/liblz4.so.1 new file mode 100644 index 00000000..837d0f67 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/liblz4.so.1 differ diff --git a/mysql/lib/x86_64-linux-gnu/libm.so.6 b/mysql/lib/x86_64-linux-gnu/libm.so.6 new file mode 100644 index 00000000..68c32a34 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libm.so.6 differ diff --git a/mysql/lib/x86_64-linux-gnu/libnuma.so.1 b/mysql/lib/x86_64-linux-gnu/libnuma.so.1 new file mode 100644 index 00000000..2ca29e74 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libnuma.so.1 differ diff --git a/mysql/lib/x86_64-linux-gnu/libprotobuf-lite.so.23 b/mysql/lib/x86_64-linux-gnu/libprotobuf-lite.so.23 new file mode 100644 index 00000000..3a3f89f8 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libprotobuf-lite.so.23 differ diff --git a/mysql/lib/x86_64-linux-gnu/libssl.so.3 b/mysql/lib/x86_64-linux-gnu/libssl.so.3 new file mode 100644 index 00000000..4ed31908 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libssl.so.3 differ diff --git a/mysql/lib/x86_64-linux-gnu/libstdc++.so.6 b/mysql/lib/x86_64-linux-gnu/libstdc++.so.6 new file mode 100644 index 00000000..9bbea500 Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libstdc++.so.6 differ diff --git a/mysql/lib/x86_64-linux-gnu/libzstd.so.1 b/mysql/lib/x86_64-linux-gnu/libzstd.so.1 new file mode 100644 index 00000000..9867016c Binary files /dev/null and b/mysql/lib/x86_64-linux-gnu/libzstd.so.1 differ diff --git a/mysql/lib64/ld-linux-x86-64.so.2 b/mysql/lib64/ld-linux-x86-64.so.2 new file mode 100755 index 00000000..89e84b01 Binary files /dev/null and b/mysql/lib64/ld-linux-x86-64.so.2 differ diff --git a/mysql/usr/bin/ibd2sdi b/mysql/usr/bin/ibd2sdi new file mode 100755 index 00000000..44946f08 Binary files /dev/null and b/mysql/usr/bin/ibd2sdi differ diff --git a/mysql/usr/bin/innochecksum b/mysql/usr/bin/innochecksum new file mode 100755 index 00000000..9d0aee0c Binary files /dev/null and b/mysql/usr/bin/innochecksum differ diff --git a/mysql/usr/bin/my_print_defaults b/mysql/usr/bin/my_print_defaults new file mode 100755 index 00000000..b02f91bb Binary files /dev/null and b/mysql/usr/bin/my_print_defaults differ diff --git a/mysql/usr/bin/myisamchk b/mysql/usr/bin/myisamchk new file mode 100755 index 00000000..982405c7 Binary files /dev/null and b/mysql/usr/bin/myisamchk differ diff --git a/mysql/usr/bin/myisamlog b/mysql/usr/bin/myisamlog new file mode 100755 index 00000000..4f3a58f4 Binary files /dev/null and b/mysql/usr/bin/myisamlog differ diff --git a/mysql/usr/bin/myisampack b/mysql/usr/bin/myisampack new file mode 100755 index 00000000..4b657312 Binary files /dev/null and b/mysql/usr/bin/myisampack differ diff --git a/mysql/usr/bin/mysql_migrate_keyring b/mysql/usr/bin/mysql_migrate_keyring new file mode 100755 index 00000000..90d0a956 Binary files /dev/null and b/mysql/usr/bin/mysql_migrate_keyring differ diff --git a/mysql/usr/bin/mysql_secure_installation b/mysql/usr/bin/mysql_secure_installation new file mode 100755 index 00000000..c1cea42c Binary files /dev/null and b/mysql/usr/bin/mysql_secure_installation differ diff --git a/mysql/usr/bin/mysql_ssl_rsa_setup b/mysql/usr/bin/mysql_ssl_rsa_setup new file mode 100755 index 00000000..61179c8a Binary files /dev/null and b/mysql/usr/bin/mysql_ssl_rsa_setup differ diff --git a/mysql/usr/bin/mysql_tzinfo_to_sql b/mysql/usr/bin/mysql_tzinfo_to_sql new file mode 100755 index 00000000..42de8cd2 Binary files /dev/null and b/mysql/usr/bin/mysql_tzinfo_to_sql differ diff --git a/mysql/usr/bin/mysql_upgrade b/mysql/usr/bin/mysql_upgrade new file mode 100755 index 00000000..58d8e40a Binary files /dev/null and b/mysql/usr/bin/mysql_upgrade differ diff --git a/mysql/usr/bin/mysqlbinlog b/mysql/usr/bin/mysqlbinlog new file mode 100755 index 00000000..673c3d1b Binary files /dev/null and b/mysql/usr/bin/mysqlbinlog differ diff --git a/mysql/usr/bin/mysqld_multi b/mysql/usr/bin/mysqld_multi new file mode 100755 index 00000000..9410ab84 --- /dev/null +++ b/mysql/usr/bin/mysqld_multi @@ -0,0 +1,932 @@ +#!/usr/bin/perl + +# Copyright (c) 2000, 2023, Oracle and/or its affiliates. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License, version 2.0, +# as published by the Free Software Foundation. +# +# This program is also distributed with certain software (including +# but not limited to OpenSSL) that is licensed under separate terms, +# as designated in a particular file or component or in included license +# documentation. The authors of MySQL hereby grant you an additional +# permission to link the program and your derivative works with the +# separately licensed software that they have included with MySQL. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License, version 2.0, for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +use Getopt::Long; +use POSIX qw(strftime getcwd); +use File::Path qw(mkpath); + +$|=1; +$VER="2.16"; + +my @defaults_options; # Leading --no-defaults, --defaults-file, etc. + +$opt_example = 0; +$opt_help = 0; +$opt_log = undef(); +$opt_mysqladmin = "/usr/bin/mysqladmin"; +$opt_mysqld = "/usr/sbin/mysqld"; +$opt_no_log = 0; +$opt_password = undef(); +$opt_tcp_ip = 0; +$opt_user = "root"; +$opt_version = 0; +$opt_silent = 0; +$opt_verbose = 0; + +my $my_print_defaults_exists= 1; +my $logdir= undef(); + +my ($mysqld, $mysqladmin, $groupids, $homedir, $my_progname); + +$homedir = $ENV{HOME}; +$my_progname = $0; +$my_progname =~ s/.*[\/]//; + + +if (defined($ENV{UMASK})) { + my $UMASK = $ENV{UMASK}; + my $m; + my $fmode = "0640"; + + if(($UMASK =~ m/[^0246]/) || ($UMASK =~ m/^[^0]/) || (length($UMASK) != 4)) { + printf("UMASK must be a 3-digit mode with an additional leading 0 to indicate octal.\n"); + printf("The first digit will be corrected to 6, the others may be 0, 2, 4, or 6.\n"); } + else { + $fmode= substr $UMASK, 2, 2; + $fmode= "06${fmode}"; } + + if($fmode != $UMASK) { + printf("UMASK corrected from $UMASK to $fmode ...\n"); } + + $fmode= oct($fmode); + + umask($fmode); +} + + +main(); + +#### +#### main sub routine +#### + +sub main +{ + my $flag_exit= 0; + + if (!defined(my_which(my_print_defaults))) + { + # We can't throw out yet, since --version, --help, or --example may + # have been given + print "WARNING: my_print_defaults command not found.\n"; + print "Please make sure you have this command available and\n"; + print "in your path. The command is available from the latest\n"; + print "MySQL distribution.\n"; + $my_print_defaults_exists= 0; + } + + # Remove leading defaults options from @ARGV + while (@ARGV > 0) + { + last unless $ARGV[0] =~ + /^--(?:no-defaults$|(?:defaults-file|defaults-extra-file)=)/; + push @defaults_options, (shift @ARGV); + } + + foreach (@defaults_options) + { + $_ = quote_shell_word($_); + } + + # Add [mysqld_multi] options to front of @ARGV, ready for GetOptions() + unshift @ARGV, defaults_for_group('mysqld_multi'); + + # We've already handled --no-defaults, --defaults-file, etc. + if (!GetOptions("help", "example", "version", "mysqld=s", "mysqladmin=s", + "user=s", "password=s", "log=s", "no-log", + "tcp-ip", "silent", "verbose")) + { + $flag_exit= 1; + } + usage() if ($opt_help); + + if ($opt_verbose && $opt_silent) + { + print "Both --verbose and --silent have been given. Some of the warnings "; + print "will be disabled\nand some will be enabled.\n\n"; + } + + init_log() if (!defined($opt_log)); + $groupids = $ARGV[1]; + if ($opt_version) + { + print "$my_progname version $VER by Jani Tolonen\n"; + exit(0); + } + example() if ($opt_example); + if ($flag_exit) + { + print "Error with an option, see $my_progname --help for more info.\n"; + exit(1); + } + if (!defined(my_which(my_print_defaults))) + { + print "ABORT: Can't find command 'my_print_defaults'.\n"; + print "This command is available from the latest MySQL\n"; + print "distribution. Please make sure you have the command\n"; + print "in your PATH.\n"; + exit(1); + } + usage() if (!defined($ARGV[0]) || + (!($ARGV[0] =~ m/^start$/i) && + !($ARGV[0] =~ m/^stop$/i) && + !($ARGV[0] =~ m/^reload$/i) && + !($ARGV[0] =~ m/^report$/i))); + + if (!$opt_no_log) + { + w2log("$my_progname log file version $VER; run: ", + "$opt_log", 1, 0); + } + else + { + print "$my_progname log file version $VER; run: "; + print strftime "%a %b %e %H:%M:%S %Y", localtime; + print "\n"; + } + if (($ARGV[0] =~ m/^start$/i) || ($ARGV[0] =~ m/^reload$/i)) + { + if (!defined(($mysqld= my_which($opt_mysqld))) && $opt_verbose) + { + print "WARNING: Couldn't find the default mysqld binary.\n"; + print "Tried: $opt_mysqld\n"; + print "This is OK, if you are using option \"mysqld=...\" in "; + print "groups [mysqldN] separately for each.\n\n"; + } + if ($ARGV[0] =~ m/^start$/i) { + start_mysqlds(); + } elsif ($ARGV[0] =~ m/^reload$/i) { + reload_mysqlds(); + } + } + else + { + if (!defined(($mysqladmin= my_which($opt_mysqladmin))) && $opt_verbose) + { + print "WARNING: Couldn't find the default mysqladmin binary.\n"; + print "Tried: $opt_mysqladmin\n"; + print "This is OK, if you are using option \"mysqladmin=...\" in "; + print "groups [mysqldN] separately for each.\n\n"; + } + if ($ARGV[0] =~ m/^report$/i) + { + report_mysqlds(); + } + else + { + stop_mysqlds(); + } + } +} + +# +# Quote word for shell +# + +sub quote_shell_word +{ + my ($option)= @_; + + $option =~ s!([^\w=./-])!\\$1!g; + return $option; +} + +sub defaults_for_group +{ + my ($group) = @_; + + return () unless $my_print_defaults_exists; + + my $com= join ' ', 'my_print_defaults', @defaults_options, $group; + my @defaults = `$com`; + chomp @defaults; + return @defaults; +} + +#### +#### Init log file. Check for appropriate place for log file, in the following +#### order: my_print_defaults mysqld datadir, /usr/share/mysql +#### + +sub init_log +{ + foreach my $opt (defaults_for_group('mysqld')) + { + if ($opt =~ m/^--datadir=(.*)/ && -d "$1" && -w "$1") + { + $logdir= $1; + } + } + if (!defined($logdir)) + { + $logdir= "/usr/share/mysql" if (-d "/usr/share/mysql" && -w "/usr/share/mysql"); + } + if (!defined($logdir)) + { + # Log file was not specified and we could not log to a standard place, + # so log file be disabled for now. + if (!$opt_silent) + { + print "WARNING: Log file disabled. Maybe directory or file isn't writable?\n"; + } + $opt_no_log= 1; + } + else + { + $opt_log= "$logdir/mysqld_multi.log"; + } +} + +#### +#### Report living and not running MySQL servers +#### + +sub report_mysqlds +{ + my (@groups, $com, $i, @options, $pec); + + print "Reporting MySQL servers\n"; + if (!$opt_no_log) + { + w2log("\nReporting MySQL servers","$opt_log",0,0); + } + @groups = &find_groups($groupids); + for ($i = 0; defined($groups[$i]); $i++) + { + $com= get_mysqladmin_options($i, @groups); + $com.= " ping >> /dev/null 2>&1"; + system($com); + $pec = $? >> 8; + if ($pec) + { + print "MySQL server from group: $groups[$i] is not running\n"; + if (!$opt_no_log) + { + w2log("MySQL server from group: $groups[$i] is not running", + "$opt_log", 0, 0); + } + } + else + { + print "MySQL server from group: $groups[$i] is running\n"; + if (!$opt_no_log) + { + w2log("MySQL server from group: $groups[$i] is running", + "$opt_log", 0, 0); + } + } + } + if (!$i) + { + print "No groups to be reported (check your GNRs)\n"; + if (!$opt_no_log) + { + w2log("No groups to be reported (check your GNRs)", "$opt_log", 0, 0); + } + } +} + +#### +#### start multiple servers +#### + +sub start_mysqlds() +{ + my (@groups, $com, $tmp, $i, @options, $j, $mysqld_found, $info_sent); + + if (!$opt_no_log) + { + w2log("\nStarting MySQL servers\n","$opt_log",0,0); + } + else + { + print "\nStarting MySQL servers\n"; + } + @groups = &find_groups($groupids); + for ($i = 0; defined($groups[$i]); $i++) + { + @options = defaults_for_group($groups[$i]); + + $basedir_found= 0; # The default + $mysqld_found= 1; # The default + $mysqld_found= 0 if (!length($mysqld)); + + # Initialize the command. + $com= "$mysqld"; + + # Initialize the command option list, process the options, + # reset command if relevant, append key options to command line. + for ($j = 0, $tmp= ""; defined($options[$j]); $j++) + { + if ("--datadir=" eq substr($options[$j], 0, 10)) { + $datadir = $options[$j]; + $datadir =~ s/\-\-datadir\=//; + eval { mkpath($datadir) }; + if ($@) { + print "FATAL ERROR: Cannot create data directory $datadir: $!\n"; + exit(1); + } + # Quote and append 'datadir' to command line. + $options[$j]= quote_shell_word($options[$j]); + $tmp.= " $options[$j]"; + } + elsif ("--mysqladmin=" eq substr($options[$j], 0, 13)) + { + # catch this and ignore + } + elsif ("--mysqld=" eq substr($options[$j], 0, 9)) + { + $options[$j]=~ s/\-\-mysqld\=//; + # Reset command. + $com= $options[$j]; + $mysqld_found= 1; + } + elsif ("--basedir=" eq substr($options[$j], 0, 10)) + { + $basedir= $options[$j]; + $basedir =~ s/^--basedir=//; + $basedir_found= 1; + # Quote and append 'basedir' to command line. + $options[$j]= quote_shell_word($options[$j]); + $tmp.= " $options[$j]"; + } + else + { + # Quote and append additional options to command line. + $options[$j]= quote_shell_word($options[$j]); + $tmp.= " $options[$j]"; + } + } + if ($opt_verbose && $com =~ m/\/(safe_mysqld|mysqld_safe)$/ && !$info_sent) + { + print "WARNING: $1 is being used to start mysqld. In this case you "; + print "may need to pass\n\"ledir=...\" under groups [mysqldN] to "; + print "$1 in order to find the actual mysqld binary.\n"; + print "ledir (library executable directory) should be the path to the "; + print "wanted mysqld binary.\n\n"; + $info_sent= 1; + } + # Prepare command line by appending command and option list, and redirect output. + $com.= $tmp; + $com.= " >> $opt_log 2>&1" if (!$opt_no_log); + if (!$mysqld_found) + { + print "\n"; + print "FATAL ERROR: Tried to start mysqld under group [$groups[$i]], "; + print "but no mysqld binary was found.\n"; + print "Please add \"mysqld=...\" in group [mysqld_multi], or add it to "; + print "group [$groups[$i]] separately.\n"; + exit(1); + } + if ($basedir_found) + { + $curdir=getcwd(); + chdir($basedir) or die "Can't change to datadir $basedir"; + } + # Prepare datadir by initializing the server, unless this is already done. + if (! -d $datadir."/mysql") { + if (-w $datadir) { + print "\n\nInstalling new database in $datadir\n\n"; + system($com." --initialize"); + } else { + print "\n"; + print "FATAL ERROR: Tried to create mysqld under group [$groups[$i]],\n"; + print "but the data directory is not writable.\n"; + print "data directory used: $datadir\n"; + exit(1); + } + } + if (! -d $datadir."/mysql") { + print "\n"; + print "FATAL ERROR: Tried to start mysqld under group [$groups[$i]],\n"; + print "but no data directory was found or could be created.\n"; + print "data directory used: $datadir\n"; + exit(1); + } + # Start the command in the background. + system($com." &"); + if ($basedir_found) + { + chdir($curdir) or die "Can't change back to original dir $curdir"; + } + } + if (!$i && !$opt_no_log) + { + w2log("No MySQL servers to be started (check your GNRs)", + "$opt_log", 0, 0); + } +} + +#### +#### reload multiple servers +#### + +sub reload_mysqlds() +{ + my (@groups, $com, $tmp, $i, @options, $j); + + if (!$opt_no_log) + { + w2log("\nReloading MySQL servers\n","$opt_log",0,0); + } + else + { + print "\nReloading MySQL servers\n"; + } + @groups = &find_groups($groupids); + for ($i = 0; defined($groups[$i]); $i++) + { + $mysqld_server = $mysqld; + @options = defaults_for_group($groups[$i]); + + for ($j = 0, $tmp= ""; defined($options[$j]); $j++) + { + if ("--mysqladmin=" eq substr($options[$j], 0, 13)) + { + # catch this and ignore + } + elsif ("--mysqld=" eq substr($options[$j], 0, 9)) + { + $options[$j] =~ s/\-\-mysqld\=//; + $mysqld_server = $options[$j]; + } + elsif ("--pid-file=" eq substr($options[$j], 0, 11)) + { + $options[$j] =~ s/\-\-pid-file\=//; + $pid_file = $options[$j]; + } + } + $com = "killproc -p $pid_file -HUP $mysqld_server"; + system($com); + + $com = "touch $pid_file"; + system($com); + } + if (!$i && !$opt_no_log) + { + w2log("No MySQL servers to be reloaded (check your GNRs)", + "$opt_log", 0, 0); + } +} + +### +#### stop multiple servers +#### + +sub stop_mysqlds() +{ + my (@groups, $com, $i, @options); + + if (!$opt_no_log) + { + w2log("\nStopping MySQL servers\n","$opt_log",0,0); + } + else + { + print "\nStopping MySQL servers\n"; + } + @groups = &find_groups($groupids); + for ($i = 0; defined($groups[$i]); $i++) + { + $com= get_mysqladmin_options($i, @groups); + $com.= " shutdown"; + $com.= " >> $opt_log 2>&1" if (!$opt_no_log); + $com.= " &"; + system($com); + } + if (!$i && !$opt_no_log) + { + w2log("No MySQL servers to be stopped (check your GNRs)", + "$opt_log", 0, 0); + } +} + +#### +#### Sub function for mysqladmin option parsing +#### + +sub get_mysqladmin_options +{ + my ($i, @groups)= @_; + my ($mysqladmin_found, $com, $tmp, $j); + + @options = defaults_for_group($groups[$i]); + + $mysqladmin_found= 1; # The default + $mysqladmin_found= 0 if (!length($mysqladmin)); + $com = "$mysqladmin"; + $tmp = " -u $opt_user"; + if (defined($opt_password)) { + my $pw= $opt_password; + # Protect single quotes in password + $pw =~ s/'/'"'"'/g; + $tmp.= " -p'$pw'"; + } + $tmp.= $opt_tcp_ip ? " -h 127.0.0.1" : ""; + for ($j = 0; defined($options[$j]); $j++) + { + if ("--mysqladmin=" eq substr($options[$j], 0, 13)) + { + $options[$j]=~ s/\-\-mysqladmin\=//; + $com= $options[$j]; + $mysqladmin_found= 1; + } + elsif ((($options[$j] =~ m/^(\-\-socket\=)(.*)$/) && !$opt_tcp_ip) || + ($options[$j] =~ m/^(\-\-port\=)(.*)$/)) + { + $tmp.= " $options[$j]"; + } + } + if (!$mysqladmin_found) + { + print "\n"; + print "FATAL ERROR: Tried to use mysqladmin in group [$groups[$i]], "; + print "but no mysqladmin binary was found.\n"; + print "Please add \"mysqladmin=...\" in group [mysqld_multi], or "; + print "in group [$groups[$i]].\n"; + exit(1); + } + $com.= $tmp; + return $com; +} + +# Return a list of option files which can be opened. Similar, but not +# identical, to behavior of my_search_option_files() +sub list_defaults_files +{ + my %opt; + foreach (@defaults_options) + { + return () if /^--no-defaults$/; + $opt{$1} = $2 if /^--defaults-(extra-file|file)=(.*)$/; + } + + return ($opt{file}) if exists $opt{file}; + + my %seen; # Don't list the same file more than once + return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ } + ('/etc/my.cnf', + '/etc/mysql/my.cnf', + '/usr/my.cnf', + ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef), + $opt{'extra-file'}, + ($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef)); +} + + +# Takes a specification of GNRs (see --help), and returns a list of matching +# groups which actually are mentioned in a relevant config file +sub find_groups +{ + my ($raw_gids) = @_; + + my %gids; + my @groups; + + if (defined($raw_gids)) + { + # Make a hash of the wanted group ids + foreach my $raw_gid (split ',', $raw_gids) + { + # Match 123 or 123-456 + my ($start, $end) = ($raw_gid =~ /^\s*(\d+)(?:\s*-\s*(\d+))?\s*$/); + $end = $start if not defined $end; + if (not defined $start or $end < $start or $start < 0) + { + print "ABORT: Bad GNR: $raw_gid; see $my_progname --help\n"; + exit(1); + } + + foreach my $i ($start .. $end) + { + # Use $i + 0 to normalize numbers (002 + 0 -> 2) + $gids{$i + 0}= 1; + } + } + } + + my @defaults_files = list_defaults_files(); + #warn "@{[sort keys %gids]} -> @defaults_files\n"; + foreach my $file (@defaults_files) + { + next unless open CONF, "< $file"; + + while () + { + if (/^\s*\[\s*(mysqld)(\d+)\s*\]\s*$/) + { + #warn "Found a group: $1$2\n"; + # Use $2 + 0 to normalize numbers (002 + 0 -> 2) + if (not defined($raw_gids) or $gids{$2 + 0}) + { + push @groups, "$1$2"; + } + } + } + + close CONF; + } + return @groups; +} + +#### +#### w2log: Write to a logfile. +#### 1.arg: append to the log file (given string, or from a file. if a file, +#### file will be read from $opt_logdir) +#### 2.arg: logfile -name (w2log assumes that the logfile is in $opt_logdir). +#### 3.arg. 0 | 1, if true, print current date to the logfile. 3. arg will +#### be ignored, if 1. arg is a file. +#### 4.arg. 0 | 1, if true, first argument is a file, else a string +#### + +sub w2log +{ + my ($msg, $file, $date_flag, $is_file)= @_; + my (@data); + + open (LOGFILE, ">>$opt_log") + or die "FATAL: w2log: Couldn't open log file: $opt_log\n"; + + if ($is_file) + { + open (FROMFILE, "<$msg") && (@data=) && + close(FROMFILE) + or die "FATAL: w2log: Couldn't open file: $msg\n"; + foreach my $line (@data) + { + print LOGFILE "$line"; + } + } + else + { + print LOGFILE "$msg"; + print LOGFILE strftime "%a %b %e %H:%M:%S %Y", localtime if ($date_flag); + print LOGFILE "\n"; + } + close (LOGFILE); + return; +} + +#### +#### my_which is used, because we can't assume that every system has the +#### which -command. my_which can take only one argument at a time. +#### Return values: requested system command with the first found path, +#### or undefined, if not found. +#### + +sub my_which +{ + my ($command) = @_; + my (@paths, $path); + + # If the argument is not 'my_print_defaults' then it would be of the format + # / + return $command if ($command ne 'my_print_defaults' && -f $command && + -x $command); + + @paths = split(':', $ENV{'PATH'}); + foreach $path (@paths) + { + $path .= "/$command"; + return $path if (-f $path && -x $path); + } + return undef(); +} + + +#### +#### example +#### + +sub example +{ + print <&2 + echo "The first digit will be corrected to 6, the others may be 0, 2, 4, or 6." >&2 +fi +fmode=`echo "$fmode"|cut -c3-4` +fmode="6$fmode" +if [ "x$UMASK" != "x0$fmode" ] +then + echo "UMASK corrected from $UMASK to 0$fmode ..." +fi + +defaults= +case "$1" in + --no-defaults|--defaults-file=*|--defaults-extra-file=*) + defaults="$1"; shift + ;; +esac + +usage () { + cat <> "$err_log" + fi + ;; + syslog) logger -t "$syslog_tag_mysqld_safe" -p "$priority" "$*" ;; + both) + if [ -w / -o "$USER" = "root" ]; then + true + else + echo "$msg" >> "$err_log" + fi + logger -t "$syslog_tag_mysqld_safe" -p "$priority" "$*" + ;; + *) + echo "Internal program error (non-fatal):" \ + " unknown logging method '$logging'" >&2 + ;; + esac +} + +log_error () { + log_generic ${syslog_facility}.error "$@" >&2 +} + +log_notice () { + log_generic ${syslog_facility}.notice "$@" +} + +eval_log_error () { + cmd="$1" + case $logging in + file) + if [ -w / -o "$USER" = "root" ]; then + cmd="$cmd > /dev/null 2>&1" + else + cmd="$cmd >> "`shell_quote_string "$err_log"`" 2>&1" + fi + ;; + syslog) + cmd="$cmd --log-syslog=1 --log-syslog-facility=$syslog_facility '--log-syslog-tag=$syslog_tag' > /dev/null 2>&1" + ;; + both) + if [ -w / -o "$USER" = "root" ]; then + cmd="$cmd --log-syslog=1 --log-syslog-facility=$syslog_facility '--log-syslog-tag=$syslog_tag' > /dev/null 2>&1" + else + cmd="$cmd --log-syslog=1 --log-syslog-facility=$syslog_facility '--log-syslog-tag=$syslog_tag' >> "`shell_quote_string "$err_log"`" 2>&1" + fi + ;; + *) + echo "Internal program error (non-fatal):" \ + " unknown logging method '$logging'" >&2 + ;; + esac + + #echo "Running mysqld: [$cmd]" + cmd="env MYSQLD_PARENT_PID=$$ $cmd" + eval "$cmd" +} + +shell_quote_string() { + # This sed command makes sure that any special chars are quoted, + # so the arg gets passed exactly to the server. + echo "$1" | sed -e 's,\([^a-zA-Z0-9/_.=-]\),\\\1,g' +} + +parse_arguments() { + # We only need to pass arguments through to the server if we don't + # handle them here. So, we collect unrecognized options (passed on + # the command line) into the args variable. + pick_args= + if test "$1" = PICK-ARGS-FROM-ARGV + then + pick_args=1 + shift + fi + + for arg do + # the parameter after "=", or the whole $arg if no match + val=`echo "$arg" | sed -e 's;^--[^=]*=;;'` + # what's before "=", or the whole $arg if no match + optname=`echo "$arg" | sed -e 's/^\(--[^=]*\)=.*$/\1/'` + # replace "_" by "-" ; mysqld_safe must accept "_" like mysqld does. + optname_subst=`echo "$optname" | sed 's/_/-/g'` + arg=`echo $arg | sed "s/^$optname/$optname_subst/"` + case "$arg" in + # these get passed explicitly to mysqld + --basedir=*) MY_BASEDIR_VERSION="$val" ;; + --datadir=*) + case $val in + /) DATADIR=$val ;; + *) DATADIR="`echo $val | sed 's;/*$;;'`" ;; + esac + ;; + --pid-file=*) pid_file="$val" ;; + --plugin-dir=*) PLUGIN_DIR="$val" ;; + --user=*) user="$val"; SET_USER=1 ;; + + # these might have been set in a [mysqld_safe] section of my.cnf + # they are added to mysqld command line to override settings from my.cnf + --log-error=*) err_log="$val" ;; + --port=*) mysql_tcp_port="$val" ;; + --socket=*) mysql_unix_port="$val" ;; + + # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! + --core-file-size=*) core_file_size="$val" ;; + --ledir=*) + if [ -z "$pick_args" ]; then + log_error "--ledir option can only be used as command line option, found in config file" + exit 1 + fi + ledir="$val" + ;; + --malloc-lib=*) set_malloc_lib "$val" ;; + --mysqld=*) + if [ -z "$pick_args" ]; then + log_error "--mysqld option can only be used as command line option, found in config file" + exit 1 + fi + MYSQLD="$val" ;; + --mysqld-version=*) + if [ -z "$pick_args" ]; then + log_error "--mysqld-version option can only be used as command line option, found in config file" + exit 1 + fi + if test -n "$val" + then + MYSQLD="mysqld-$val" + PLUGIN_VARIANT="/$val" + else + MYSQLD="mysqld" + fi + ;; + --nice=*) niceness="$val" ;; + --open-files-limit=*) open_files="$val" ;; + --open_files_limit=*) open_files="$val" ;; + --skip-kill-mysqld*) KILL_MYSQLD=0 ;; + --mysqld-safe-log-timestamps=*) timestamp_format="$val" ;; + --syslog) want_syslog=1 ;; + --skip-syslog) want_syslog=0 ;; + --syslog-tag=*) syslog_tag="$val" ;; + --timezone=*) TZ="$val"; export TZ; ;; + + --help) usage ;; + + *) + if test -n "$pick_args" + then + append_arg_to_args "$arg" + fi + ;; + esac + done +} + + +# Add a single shared library to the list of libraries which will be added to +# LD_PRELOAD for mysqld +# +# Since LD_PRELOAD is a space-separated value (for historical reasons), if a +# shared lib's path contains spaces, that path will be prepended to +# LD_LIBRARY_PATH and stripped from the lib value. +add_mysqld_ld_preload() { + lib_to_add="$1" + log_notice "Adding '$lib_to_add' to LD_PRELOAD for mysqld" + + case "$lib_to_add" in + *' '*) + # Must strip path from lib, and add it to LD_LIBRARY_PATH + lib_file=`basename "$lib_to_add"` + case "$lib_file" in + *' '*) + # The lib file itself has a space in its name, and can't + # be used in LD_PRELOAD + log_error "library name '$lib_to_add' contains spaces and can not be used with LD_PRELOAD" + exit 1 + ;; + esac + lib_path=`dirname "$lib_to_add"` + lib_to_add="$lib_file" + [ -n "$mysqld_ld_library_path" ] && mysqld_ld_library_path="$mysqld_ld_library_path:" + mysqld_ld_library_path="$mysqld_ld_library_path$lib_path" + ;; + esac + + # LD_PRELOAD is a space-separated + [ -n "$mysqld_ld_preload" ] && mysqld_ld_preload="$mysqld_ld_preload " + mysqld_ld_preload="${mysqld_ld_preload}$lib_to_add" +} + + +# Returns LD_PRELOAD (and LD_LIBRARY_PATH, if needed) text, quoted to be +# suitable for use in the eval that calls mysqld. +# +# All values in mysqld_ld_preload are prepended to LD_PRELOAD. +mysqld_ld_preload_text() { + text= + + if [ -n "$mysqld_ld_preload" ]; then + new_text="$mysqld_ld_preload" + [ -n "$LD_PRELOAD" ] && new_text="$new_text $LD_PRELOAD" + text="${text}LD_PRELOAD="`shell_quote_string "$new_text"`' ' + fi + + if [ -n "$mysqld_ld_library_path" ]; then + new_text="$mysqld_ld_library_path" + [ -n "$LD_LIBRARY_PATH" ] && new_text="$new_text:$LD_LIBRARY_PATH" + text="${text}LD_LIBRARY_PATH="`shell_quote_string "$new_text"`' ' + fi + + echo "$text" +} + +# set_malloc_lib LIB +# - If LIB is empty, do nothing and return +# - If LIB is an absolute path, assume it is a malloc shared library +# +# Put LIB in mysqld_ld_preload, which will be added to LD_PRELOAD when +# running mysqld. See ld.so for details. +set_malloc_lib() { + # This list is kept intentionally simple. + malloc_dirs="/usr/lib /usr/lib64 /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu" + malloc_lib="$1" + + # Allow --malloc-lib='' to override other settings + [ -z "$malloc_lib" ] && return + + case "$malloc_lib" in + /*) + if [ ! -r "$malloc_lib" ]; then + log_error "--malloc-lib can not be read and will not be used" + exit 1 + fi + + # Restrict to a the list in $malloc_dirs above + case "`dirname "$malloc_lib"`" in + /usr/lib) ;; + /usr/lib64) ;; + /usr/lib/i386-linux-gnu) ;; + /usr/lib/x86_64-linux-gnu) ;; + *) + log_error "--malloc-lib must be located in one of the directories: $malloc_dirs" + exit 1 + ;; + esac + ;; + *) + log_error "--malloc-lib must be an absolute path ignoring value '$malloc_lib'" + exit 1 + ;; + esac + + add_mysqld_ld_preload "$malloc_lib" +} + +find_basedir_from_cmdline () { + for arg in "$@"; do + case $arg in + --basedir=*) + MY_BASEDIR_VERSION="`echo "$arg" | sed -e 's;^--[^=]*=;;'`" + # Convert to full path + cd "$MY_BASEDIR_VERSION" + if [ $? -ne 0 ] ; then + log_error "--basedir set to '$MY_BASEDIR_VERSION', however could not access directory" + exit 1 + fi + MY_BASEDIR_VERSION="`pwd`" + ;; + esac + done +} + +# +# First, try to find BASEDIR and ledir (where mysqld is) +# + +oldpwd="`pwd`" + +# Args not parsed yet, check if --basedir was given on command line +find_basedir_from_cmdline "$@" + +# --basedir is already overridden on command line +if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION" ; then + # Search for mysqld and set ledir + for dir in sbin libexec sbin bin ; do + if test -x "$MY_BASEDIR_VERSION/$dir/mysqld" ; then + ledir="$MY_BASEDIR_VERSION/$dir" + break + fi + done + +else + # Basedir should be parent dir of bindir, unless some non-standard + # layout is used + + cd "`dirname $0`" + if [ -h "$0" ] ; then + realpath="`ls -l "$0" | awk '{print $NF}'`" + cd "`dirname "$realpath"`" + fi + cd .. + MY_PWD="`pwd`" + + # Search for mysqld and set ledir and BASEDIR + for dir in sbin libexec sbin bin ; do + if test -x "$MY_PWD/$dir/mysqld" ; then + MY_BASEDIR_VERSION="$MY_PWD" + ledir="$MY_BASEDIR_VERSION/$dir" + break + fi + done + + # If we still didn't find anything, use the compiled-in defaults + if test -z "$MY_BASEDIR_VERSION" ; then + MY_BASEDIR_VERSION='/usr' + ledir='/usr/sbin' + fi +fi + +# +# Second, try to find the data directory +# + +# Try where the binary installs put it +if test -d $MY_BASEDIR_VERSION/data/mysql +then + DATADIR=$MY_BASEDIR_VERSION/data +# Or just give up and use our compiled-in default +else + DATADIR=/var/lib/mysql +fi + +if test -z "$MYSQL_HOME" +then + MYSQL_HOME=$MY_BASEDIR_VERSION +fi +export MYSQL_HOME + + +# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe] +# and then merge with the command line arguments +if test -x "$MY_BASEDIR_VERSION/bin/my_print_defaults" ; then + print_defaults="$MY_BASEDIR_VERSION/bin/my_print_defaults" +elif test -x "/usr/bin/my_print_defaults" ; then + print_defaults="/usr/bin/my_print_defaults" +else + print_defaults="my_print_defaults" +fi + +append_arg_to_args () { + args="$args "`shell_quote_string "$1"` +} + +args= + +cd "$oldpwd" + +SET_USER=2 +parse_arguments `$print_defaults $defaults --loose-verbose mysqld server` +if test $SET_USER -eq 2 +then + SET_USER=0 +fi + +parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld` +parse_arguments PICK-ARGS-FROM-ARGV "$@" + +# +# Sort out date command from $timestamp_format early so we'll start off +# with correct log messages. +# +case "$timestamp_format" in + UTC|utc) DATE="date -u +%Y-%m-%dT%H:%M:%S.%06NZ";; + SYSTEM|system) DATE="date +%Y-%m-%dT%H:%M:%S.%06N%:z";; + HYPHEN|hyphen) DATE="date +'%Y-%m-%d %H:%M:%S'";; + LEGACY|legacy) DATE="date +'%y%m%d %H:%M:%S'";; + *) DATE="date -u +%Y-%m-%dT%H:%M:%S.%06NZ"; + log_error "unknown data format $timestamp_format, using UTC";; +esac + +# +# Try to find the plugin directory +# + +# Use user-supplied argument +if [ -n "${PLUGIN_DIR}" ]; then + plugin_dir="${PLUGIN_DIR}" +else + # Try to find plugin dir relative to basedir + for dir in lib64/mysql/plugin lib64/plugin lib/mysql/plugin lib/plugin + do + if [ -d "${MY_BASEDIR_VERSION}/${dir}" ]; then + plugin_dir="${MY_BASEDIR_VERSION}/${dir}" + break + fi + done + # Give up and use compiled-in default + if [ -z "${plugin_dir}" ]; then + plugin_dir='/usr/lib/mysql/plugin' + fi +fi +plugin_dir="${plugin_dir}${PLUGIN_VARIANT}" + +# Determine what logging facility to use + +# Ensure that 'logger' exists, if it's requested +if [ $want_syslog -eq 1 ] +then + my_which logger > /dev/null 2>&1 + if [ $? -ne 0 ] + then + log_error "--syslog requested, but no 'logger' program found. Please ensure that 'logger' is in your PATH, or do not specify the --syslog option to mysqld_safe." + exit 1 + fi +fi + +if [ $want_syslog -eq 1 ] +then + if [ -n "$syslog_tag" ] + then + # Sanitize the syslog tag + syslog_tag=`echo "$syslog_tag" | sed -e 's/[^a-zA-Z0-9_-]/_/g'` + syslog_tag_mysqld_safe="${syslog_tag_mysqld_safe}-$syslog_tag" + syslog_tag_mysqld="${syslog_tag_mysqld}-$syslog_tag" + fi + log_notice "Logging to syslog." + logging=syslog +fi + +if [ -n "$err_log" -o $want_syslog -eq 0 ] +then + if [ -n "$err_log" ] + then + # mysqld adds ".err" if there is no extension on the --log-error + # argument; must match that here, or mysqld_safe will write to a + # different log file than mysqld + + # mysqld does not add ".err" to "--log-error=foo."; it considers a + # trailing "." as an extension + + if expr "$err_log" : '.*\.[^/]*$' > /dev/null + then + : + else + err_log="$err_log".err + fi + + err_log_append="$err_log" + case "$err_log" in + /* ) ;; + ./*|../*) + # Preparing absolute path from the relative path value specified for the + # --log-error argument. + # + # Absolute path will be prepared for the value of following form + # ./bar/foo OR + # ../old_bar/foo + # for --log-error argument. + # + # Note: If directory of log file name does not exists or + # if write or execute permissions are missing on directory then + # --log-error is set $DATADIR/`hostname`.err + + log_dir_name="$(dirname "$err_log")"; + if [ ! -d "$log_dir_name" ] + then + log_notice "Directory "$log_dir_name" does not exists."; + err_log=$DATADIR/`hostname`.err + elif [ ! -x "$log_dir_name" -o ! -w "$log_dir_name" ] + then + log_notice "Do not have Execute or Write permissions on directory "$log_dir_name"."; + err_log=$DATADIR/`hostname`.err + else + err_log=$(cd $log_dir_name && pwd -P)/$(basename "$err_log") + fi + ;; + * ) err_log="$DATADIR/$err_log" ;; + esac + else + err_log=$DATADIR/`hostname`.err + err_log_append=`hostname`.err + fi + + append_arg_to_args "--log-error=$err_log_append" + + if [ $want_syslog -eq 1 ] + then + logging=both + else + logging=file + fi +fi + +logdir=`dirname "$err_log"` +# Change the err log to the right user, if possible and it is in use +if [ $logging = "file" -o $logging = "both" ]; then + if [ ! -e "$err_log" -a ! -h "$err_log" ]; then + if test -w / -o "$USER" = "root"; then + case $logdir in + /var/log) + ( + umask 0137 + set -o noclobber + > "$err_log" && chown $user "$err_log" + ) ;; + *) ;; + esac + else + ( + umask 0137 + set -o noclobber + > "$err_log" + ) + fi + fi + + if [ -f "$err_log" -o -p "$err_log" ]; then # Log to err_log file + log_notice "Logging to '$err_log'." + elif [ "x$user" = "xroot" ]; then # running as root, mysqld can create log file; continue + echo "Logging to '$err_log'." >&2 + else + case $logdir in + # We can't create $err_log, however mysqld can; continue + /tmp|/var/tmp|/var/log/mysql|$DATADIR) + echo "Logging to '$err_log'." >&2 + ;; + # We can't create $err_log and don't know if mysqld can; error out + *) + log_error "error: log-error set to '$err_log', however file don't exists. Create writable for user '$user'." + exit 1 + ;; + esac + fi +fi + +USER_OPTION="" +if test -w / -o "$USER" = "root" +then + if test "$user" != "root" -o $SET_USER = 1 + then + USER_OPTION="--user=$user" + fi + if test -n "$open_files" + then + ulimit -n $open_files + fi +fi + +if test -n "$open_files" +then + append_arg_to_args "--open-files-limit=$open_files" +fi + +safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-/var/run/mysqld/mysqld.sock}} +# Check that directory for $safe_mysql_unix_port exists +mysql_unix_port_dir=`dirname $safe_mysql_unix_port` +if [ ! -d $mysql_unix_port_dir ] +then + log_error "Directory '$mysql_unix_port_dir' for UNIX socket file don't exists." + exit 1 +fi + +# If the user doesn't specify a binary, we assume name "mysqld" +if test -z "$MYSQLD" +then + MYSQLD=mysqld +fi + +if test ! -x "$ledir/$MYSQLD" +then + log_error "The file $ledir/$MYSQLD +does not exist or is not executable. Please cd to the mysql installation +directory and restart this script from there as follows: +./bin/mysqld_safe& +See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information" + exit 1 +fi + +if test -z "$pid_file" +then + pid_file="$DATADIR/`hostname`.pid" + pid_file_append="`hostname`.pid" +else + pid_file_append="$pid_file" + case "$pid_file" in + /* ) ;; + * ) pid_file="$DATADIR/$pid_file" ;; + esac +fi +append_arg_to_args "--pid-file=$pid_file_append" + +if test -n "$mysql_unix_port" +then + append_arg_to_args "--socket=$mysql_unix_port" +fi +if test -n "$mysql_tcp_port" +then + append_arg_to_args "--port=$mysql_tcp_port" +fi + +if test $niceness -eq 0 +then + NOHUP_NICENESS="nohup" +else + NOHUP_NICENESS="nohup nice -$niceness" +fi + +# Using nice with no args to get the niceness level is GNU-specific. +# This check could be extended for other operating systems (e.g., +# BSD could use "nohup sh -c 'ps -o nice -p $$' | tail -1"). +# But, it also seems that GNU nohup is the only one which messes +# with the priority, so this is okay. +if nohup nice > /dev/null 2>&1 +then + normal_niceness=`nice` + nohup_niceness=`nohup nice 2>/dev/null` + + numeric_nice_values=1 + for val in $normal_niceness $nohup_niceness + do + case "$val" in + -[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | \ + [0-9] | [0-9][0-9] | [0-9][0-9][0-9] ) + ;; + * ) + numeric_nice_values=0 ;; + esac + done + + if test $numeric_nice_values -eq 1 + then + nice_value_diff=`expr $nohup_niceness - $normal_niceness` + if test $? -eq 0 && test $nice_value_diff -gt 0 && \ + nice --$nice_value_diff echo testing > /dev/null 2>&1 + then + # nohup increases the priority (bad), and we are permitted + # to lower the priority with respect to the value the user + # might have been given + niceness=`expr $niceness - $nice_value_diff` + NOHUP_NICENESS="nice -$niceness nohup" + fi + fi +else + if nohup echo testing > /dev/null 2>&1 + then + : + else + # nohup doesn't work on this system + NOHUP_NICENESS="" + fi +fi + +# Try to set the core file size (even if we aren't root) because many systems +# don't specify a hard limit on core file size. +if test -n "$core_file_size" +then + ulimit -c $core_file_size +fi + +# +# If there exists an old pid file, check if the daemon is already running +# Note: The switches to 'ps' may depend on your operating system +if test -f "$pid_file" +then + PID=`cat "$pid_file"` + if kill -0 $PID > /dev/null 2> /dev/null + then + if ps wwwp $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null + then # The pid contains a mysqld process + log_error "A mysqld process already exists" + exit 1 + fi + fi + if [ ! -h "$pid_file" ]; then + rm -f "$pid_file" + if test -f "$pid_file"; then + log_error "Fatal error: Can't remove the pid file: +$pid_file. +Please remove the file manually and start $0 again; +mysqld daemon not started" + exit 1 + fi + fi + if [ ! -h "$safe_mysql_unix_port" ]; then + rm -f "$safe_mysql_unix_port" + if test -f "$safe_mysql_unix_port"; then + log_error "Fatal error: Can't remove the socket file: +$safe_mysql_unix_port. +Please remove the file manually and start $0 again; +mysqld daemon not started" + exit 1 + fi + fi + if [ ! -h "$pid_file.shutdown" ]; then + rm -f "$pid_file.shutdown" + if test -f "$pid_file.shutdown"; then + log_error "Fatal error: Can't remove the shutdown file: +$pid_file.shutdown. +Please remove the file manually and start $0 again; +mysqld daemon not started" + exit 1 + fi + fi +fi + +# +# Uncomment the following lines if you want all tables to be automatically +# checked and repaired during startup. You should add sensible key_buffer +# and sort_buffer values to my.cnf to improve check performance or require +# less disk space. +# Alternatively, you can start mysqld with the "myisam-recover" option. See +# the manual for details. +# +# echo "Checking tables in $DATADIR" +# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI +# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM + +# Does this work on all systems? +#if type ulimit | grep "shell builtin" > /dev/null +#then +# ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems +#fi + +cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS" + +for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ + "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION" +do + cmd="$cmd "`shell_quote_string "$i"` +done +cmd="$cmd $args" +# Avoid 'nohup: ignoring input' warning +test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null" + +log_notice "Starting $MYSQLD daemon with databases from $DATADIR" + +# variable to track the current number of "fast" (a.k.a. subsecond) restarts +fast_restart=0 +# maximum number of restarts before throttling kicks in +max_fast_restarts=5 +# flag whether a usable sleep command exists +have_sleep=1 +while true +do + start_time=`date +%M%S` + eval_log_error "$cmd" + if [ $? -eq 16 ] ; then + dont_restart_mysqld=false + echo "Restarting mysqld..." + else + dont_restart_mysqld=true + fi + + # hypothetical: log was renamed but not + # flushed yet. we'd recreate it with + # wrong owner next time we log, so set + # it up correctly while we can! + + if [ $want_syslog -eq 0 -a ! -f "$err_log" -a ! -h "$err_log" ]; then + if test -w / -o "$USER" = "root"; then + logdir=`dirname "$err_log"` + case $logdir in + /var/log) + ( + umask 0137 + set -o noclobber + > "$err_log" && chown $user "$err_log" + ) ;; + *) ;; + esac + else + ( + umask 0137 + set -o noclobber + > "$err_log" + ) + fi + fi + + end_time=`date +%M%S` + + if $dont_restart_mysqld; then + if test ! -f "$pid_file" # This is removed if normal shutdown + then + break + else # self's mysqld crashed or other's mysqld running + PID=`cat "$pid_file"` + if kill -0 $PID > /dev/null 2> /dev/null + then # true when above pid belongs to a running mysqld process + log_error "A mysqld process with pid=$PID is already running. Aborting!!" + exit 1 + fi + fi + fi + + if test -f "$pid_file.shutdown" # created to signal that it must stop + then + log_notice "$pid_file.shutdown present. The server will not restart." + break + fi + + + # sanity check if time reading is sane and there's sleep + if test $end_time -gt 0 -a $have_sleep -gt 0 + then + # throttle down the fast restarts + if test $end_time -eq $start_time + then + fast_restart=`expr $fast_restart + 1` + if test $fast_restart -ge $max_fast_restarts + then + log_notice "The server is respawning too fast. Sleeping for 1 second." + sleep 1 + sleep_state=$? + if test $sleep_state -gt 0 + then + log_notice "The server is respawning too fast and in addition no working 'sleep' command was found. Turning off throttling." + have_sleep=0 + fi + + fast_restart=0 + fi + else + fast_restart=0 + fi + fi + + if true && test $KILL_MYSQLD -eq 1 + then + # Test if one process was hanging. + # This is only a fix for Linux (running as base 3 mysqld processes) + # but should work for the rest of the servers. + # The only thing is ps x => redhat 5 gives warnings when using ps -x. + # kill -9 is used or the process won't react on the kill. + numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"` + + log_notice "Number of processes running now: $numofproces" + I=1 + while test "$I" -le "$numofproces" + do + PROC=`ps xaww | grep "$ledir/$MYSQLD\>" | grep -v "grep" | grep "pid-file=$pid_file" | sed -n '$p'` + + for T in $PROC + do + break + done + # echo "TEST $I - $T **" + if kill -9 $T + then + log_error "$MYSQLD process hanging, pid $T - killed" + else + break + fi + I=`expr $I + 1` + done + fi + if [ ! -h "$pid_file" ]; then + rm -f "$pid_file" + fi + if [ ! -h "$safe_mysql_unix_port" ]; then + rm -f "$safe_mysql_unix_port" + fi + if [ ! -h "$pid_file.shutdown" ]; then + rm -f "$pid_file.shutdown" + fi + log_notice "mysqld restarted" +done + +if [ ! -h "$pid_file.shutdown" ]; then + rm -f "$pid_file.shutdown" +fi + +log_notice "mysqld from pid file $pid_file ended" + +if [ ! -h "$safe_pid" ]; then + rm -f "$safe_pid" # Some Extra Safety. File is deleted +fi # once the mysqld process ends. diff --git a/mysql/usr/bin/perror b/mysql/usr/bin/perror new file mode 100755 index 00000000..53e28bba Binary files /dev/null and b/mysql/usr/bin/perror differ diff --git a/mysql/usr/lib/mysql/plugin/adt_null.so b/mysql/usr/lib/mysql/plugin/adt_null.so new file mode 100644 index 00000000..43291fe2 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/adt_null.so differ diff --git a/mysql/usr/lib/mysql/plugin/auth_socket.so b/mysql/usr/lib/mysql/plugin/auth_socket.so new file mode 100644 index 00000000..cbb1aba3 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/auth_socket.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_audit_api_message_emit.so b/mysql/usr/lib/mysql/plugin/component_audit_api_message_emit.so new file mode 100644 index 00000000..ca233c1d Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_audit_api_message_emit.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_keyring_file.so b/mysql/usr/lib/mysql/plugin/component_keyring_file.so new file mode 100644 index 00000000..0ec3efd1 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_keyring_file.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_log_filter_dragnet.so b/mysql/usr/lib/mysql/plugin/component_log_filter_dragnet.so new file mode 100644 index 00000000..23f25fb1 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_log_filter_dragnet.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_log_sink_json.so b/mysql/usr/lib/mysql/plugin/component_log_sink_json.so new file mode 100644 index 00000000..137be40f Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_log_sink_json.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_log_sink_syseventlog.so b/mysql/usr/lib/mysql/plugin/component_log_sink_syseventlog.so new file mode 100644 index 00000000..1d662a44 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_log_sink_syseventlog.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_mysqlbackup.so b/mysql/usr/lib/mysql/plugin/component_mysqlbackup.so new file mode 100644 index 00000000..543230e4 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_mysqlbackup.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_query_attributes.so b/mysql/usr/lib/mysql/plugin/component_query_attributes.so new file mode 100644 index 00000000..a23a39c3 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_query_attributes.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_reference_cache.so b/mysql/usr/lib/mysql/plugin/component_reference_cache.so new file mode 100644 index 00000000..3c414d64 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_reference_cache.so differ diff --git a/mysql/usr/lib/mysql/plugin/component_validate_password.so b/mysql/usr/lib/mysql/plugin/component_validate_password.so new file mode 100644 index 00000000..5c723253 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/component_validate_password.so differ diff --git a/mysql/usr/lib/mysql/plugin/connection_control.so b/mysql/usr/lib/mysql/plugin/connection_control.so new file mode 100644 index 00000000..f7e730df Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/connection_control.so differ diff --git a/mysql/usr/lib/mysql/plugin/ddl_rewriter.so b/mysql/usr/lib/mysql/plugin/ddl_rewriter.so new file mode 100644 index 00000000..6c2ec386 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/ddl_rewriter.so differ diff --git a/mysql/usr/lib/mysql/plugin/group_replication.so b/mysql/usr/lib/mysql/plugin/group_replication.so new file mode 100644 index 00000000..f3555b9e Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/group_replication.so differ diff --git a/mysql/usr/lib/mysql/plugin/innodb_engine.so b/mysql/usr/lib/mysql/plugin/innodb_engine.so new file mode 100644 index 00000000..b4f6c90f Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/innodb_engine.so differ diff --git a/mysql/usr/lib/mysql/plugin/keyring_file.so b/mysql/usr/lib/mysql/plugin/keyring_file.so new file mode 100644 index 00000000..990a6113 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/keyring_file.so differ diff --git a/mysql/usr/lib/mysql/plugin/keyring_udf.so b/mysql/usr/lib/mysql/plugin/keyring_udf.so new file mode 100644 index 00000000..701b1ed0 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/keyring_udf.so differ diff --git a/mysql/usr/lib/mysql/plugin/libmemcached.so b/mysql/usr/lib/mysql/plugin/libmemcached.so new file mode 100644 index 00000000..7f37705b Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/libmemcached.so differ diff --git a/mysql/usr/lib/mysql/plugin/libpluginmecab.so b/mysql/usr/lib/mysql/plugin/libpluginmecab.so new file mode 100644 index 00000000..1dabd385 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/libpluginmecab.so differ diff --git a/mysql/usr/lib/mysql/plugin/locking_service.so b/mysql/usr/lib/mysql/plugin/locking_service.so new file mode 100644 index 00000000..6c1c1195 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/locking_service.so differ diff --git a/mysql/usr/lib/mysql/plugin/mypluglib.so b/mysql/usr/lib/mysql/plugin/mypluglib.so new file mode 100644 index 00000000..56c33a48 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/mypluglib.so differ diff --git a/mysql/usr/lib/mysql/plugin/mysql_clone.so b/mysql/usr/lib/mysql/plugin/mysql_clone.so new file mode 100644 index 00000000..64f479f6 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/mysql_clone.so differ diff --git a/mysql/usr/lib/mysql/plugin/mysql_no_login.so b/mysql/usr/lib/mysql/plugin/mysql_no_login.so new file mode 100644 index 00000000..df3b3caf Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/mysql_no_login.so differ diff --git a/mysql/usr/lib/mysql/plugin/rewriter.so b/mysql/usr/lib/mysql/plugin/rewriter.so new file mode 100644 index 00000000..70a86de2 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/rewriter.so differ diff --git a/mysql/usr/lib/mysql/plugin/semisync_master.so b/mysql/usr/lib/mysql/plugin/semisync_master.so new file mode 100644 index 00000000..cf900be3 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/semisync_master.so differ diff --git a/mysql/usr/lib/mysql/plugin/semisync_replica.so b/mysql/usr/lib/mysql/plugin/semisync_replica.so new file mode 100644 index 00000000..815a1e14 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/semisync_replica.so differ diff --git a/mysql/usr/lib/mysql/plugin/semisync_slave.so b/mysql/usr/lib/mysql/plugin/semisync_slave.so new file mode 100644 index 00000000..eca121d3 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/semisync_slave.so differ diff --git a/mysql/usr/lib/mysql/plugin/semisync_source.so b/mysql/usr/lib/mysql/plugin/semisync_source.so new file mode 100644 index 00000000..2d9dd36c Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/semisync_source.so differ diff --git a/mysql/usr/lib/mysql/plugin/validate_password.so b/mysql/usr/lib/mysql/plugin/validate_password.so new file mode 100644 index 00000000..dfadaceb Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/validate_password.so differ diff --git a/mysql/usr/lib/mysql/plugin/version_token.so b/mysql/usr/lib/mysql/plugin/version_token.so new file mode 100644 index 00000000..df345266 Binary files /dev/null and b/mysql/usr/lib/mysql/plugin/version_token.so differ diff --git a/mysql/usr/lib/mysql/zlib_decompress b/mysql/usr/lib/mysql/zlib_decompress new file mode 100755 index 00000000..db117909 Binary files /dev/null and b/mysql/usr/lib/mysql/zlib_decompress differ diff --git a/mysql/usr/sbin/mysqld b/mysql/usr/sbin/mysqld new file mode 100755 index 00000000..46ef2c55 Binary files /dev/null and b/mysql/usr/sbin/mysqld differ