From: Bjorn Munch Date: October 10 2012 1:18pm Subject: bzr push into mysql-trunk branch (bjorn.munch:4699 to 4700) List-Archive: http://lists.mysql.com/commits/145008 Message-Id: <20121010131815.12336.16544.4700@khepri15.no.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4700 Bjorn Munch 2012-10-10 [merge] Upmerge WL 6055 et al 5.6 ->trunk modified: scripts/mysql_install_db.pl.in support-files/CMakeLists.txt support-files/mysql.spec.sh 4699 Nirbhay Choubey 2012-10-10 [merge] Merge of patch for bug#14722862 from mysql-5.6. modified: tests/mysql_client_fw.c === modified file 'scripts/mysql_install_db.pl.in' --- a/scripts/mysql_install_db.pl.in 2012-10-10 11:05:03 +0000 +++ b/scripts/mysql_install_db.pl.in 2012-10-10 13:05:43 +0000 @@ -36,6 +36,7 @@ use Fcntl; use File::Basename; +use File::Copy; use Getopt::Long; use Sys::Hostname; use Data::Dumper; @@ -44,6 +45,7 @@ use strict; Getopt::Long::Configure("pass_through"); my @args; # Argument list filled in +my $basedir; ############################################################################## # @@ -165,20 +167,11 @@ sub parse_arguments usage() if $opt->{help}; - # To make these options acceptable for mysqld, we must prepend the name to the value - - # but only if they are set, and have not been fixed already. - if ( $opt->{'defaults-file'} && $opt->{'defaults-file'} !~ /^--/ ) + if ( $opt->{'no-defaults'} && ( $opt->{'defaults-extra-file'} || + $opt->{'defaults-file'} ) ) { - $opt->{'defaults-file'} = '--defaults-file=' . $opt->{'defaults-file'}; - } - if ( $opt->{'defaults-extra-file'} && $opt->{'defaults-extra-file'} !~ /^--/ ) - { - $opt->{'defaults-extra-file'} = '--defaults-extra-file=' . $opt->{'defaults-extra-file'}; - } - # This option has no value, so we just have to spell it in full. - if ( $opt->{'no-defaults'} && $opt->{'no-defaults'} !~ /^--/ ) - { - $opt->{'no-defaults'} = '--no-defaults='; + error($opt, + "Cannot use both --no-defaults and --defaults-[extra-]file"); } @args = @ARGV if $pick_args; @@ -206,7 +199,7 @@ sub find_in_basedir foreach my $part ( "$file","$file.exe","release/$file.exe", "debug/$file.exe","relwithdebinfo/$file.exe" ) { - my $path = "$opt->{basedir}/$dir/$part"; + my $path = "$basedir/$dir/$part"; if ( -f $path ) { return $mode eq "dir" ? dirname($path) : $path; @@ -389,6 +382,17 @@ my $opt = {}; parse_arguments($opt, 'PICK-ARGS-FROM-ARGV', @ARGV); # ---------------------------------------------------------------------- +# Actual basedir, not to be confused with --basedir option +# ---------------------------------------------------------------------- + +if ( $opt->{srcdir} ) { + $basedir= $opt->{builddir}; +} else { + $basedir= $opt->{basedir}; +} +$basedir= "@prefix@" if ! $basedir; # Default + +# ---------------------------------------------------------------------- # We can now find my_print_defaults. This script supports: # # --srcdir=path pointing to compiled source tree @@ -408,11 +412,11 @@ if ( $opt->{srcdir} ) $opt->{builddir} = $opt->{srcdir} unless $opt->{builddir}; $print_defaults = "$opt->{builddir}/extra/my_print_defaults"; } -elsif ( $opt->{basedir} ) +else { $print_defaults = find_in_basedir($opt,"file","my_print_defaults","bin","extra"); } -else +if ( ! $print_defaults ) { $print_defaults='@bindir@/my_print_defaults'; } @@ -420,13 +424,52 @@ else -x $print_defaults or -f "$print_defaults.exe" or cannot_find_file($print_defaults); +my $config_file; +my $copy_cfg_file; + +# ---------------------------------------------------------------------- +# This will be the default config file +# ---------------------------------------------------------------------- + +$config_file= "$basedir/my.cnf"; + +my $cfg_template= find_in_basedir($opt,"file","my-default.cnf", + "share","share/mysql","support-files"); +-e $cfg_template or cannot_find_file("my-default.cnf"); + +$copy_cfg_file= $config_file; +if (-e $copy_cfg_file) +{ + $copy_cfg_file =~ s/my.cnf/my-new.cnf/; + # Too early to print warning here, the user may not notice +} +open (TEMPL, $cfg_template) or error("Could not open config template"); +open (CFG, "> $copy_cfg_file") or error("Could not open config file"); +while () +{ + # Remove lines beginning with # *** which are template comments + print CFG $_ unless /^# \*\*\*/; +} +close CFG; +close TEMPL; + # ---------------------------------------------------------------------- # Now we can get arguments from the groups [mysqld] and [mysql_install_db] # in the my.cfg file, then re-run to merge with command line arguments. # ---------------------------------------------------------------------- +my $print_def_file; +if ( $opt->{'defaults-file'} ) +{ + $print_def_file= $opt->{'defaults-file'}; +} +else +{ + $print_def_file= $config_file; +} + my @default_options; -my $cmd = quote_options($print_defaults,$opt->{'defaults-file'}, +my $cmd = quote_options($print_defaults,"--defaults-file=$print_def_file", "mysqld","mysql_install_db"); open(PIPE, "$cmd |") or error($opt,"can't run $cmd: $!"); while ( ) @@ -475,10 +518,9 @@ my ($bindir,$extra_bindir,$mysqld,$pkgda if ( $opt->{srcdir} ) { - $opt->{basedir} = $opt->{builddir}; - $bindir = "$opt->{basedir}/client"; - $extra_bindir = "$opt->{basedir}/extra"; - $mysqld = "$opt->{basedir}/sql/mysqld"; + $bindir = "$basedir/client"; + $extra_bindir = "$basedir/extra"; + $mysqld = "$basedir/sql/mysqld"; $mysqld_opt = "--language=$opt->{srcdir}/sql/share/english"; $pkgdatadir = "$opt->{srcdir}/scripts"; $scriptdir = "$opt->{srcdir}/scripts"; @@ -497,7 +539,6 @@ elsif ( $opt->{basedir} ) } else { - $opt->{basedir} = '@prefix@'; $bindir = '@bindir@'; $extra_bindir = $bindir; $mysqld = '@libexecdir@/mysqld'; @@ -604,12 +645,26 @@ push(@args, "--user=$opt->{user}") if $o # FIXME use --init-file instead of --bootstrap ?! +my $defaults_option = ""; +if ( $opt->{'no-defaults'} ) +{ + $defaults_option= "--no-defaults"; +} +elsif ( $opt->{'defaults-file'} ) +{ + $defaults_option= "--defaults-file=$opt->{'defaults-file'}"; +} + +my $defaults_extra= "--defaults-extra-file=$opt->{'defaults-extra-file'}" + if $opt->{'defaults-extra-file'}; + my $mysqld_bootstrap = $ENV{MYSQLD_BOOTSTRAP} || $mysqld; my $mysqld_install_cmd_line = quote_options($mysqld_bootstrap, - $opt->{'defaults-file'}, + $defaults_option, + $defaults_extra, $mysqld_opt, "--bootstrap", - "--basedir=$opt->{basedir}", + "--basedir=$basedir", "--datadir=$opt->{ldata}", "--log-warnings=0", "--loose-skip-ndbcluster", @@ -660,8 +715,8 @@ if ( open(PIPE, "| $mysqld_install_cmd_l { # using the implicit variable $_ ! s/ABC123xyz/$escaped_password/e ; # Replace placeholder by random password - print PIPE $_; - } + print PIPE $_; + } close SQL3; tell_root_password(); } @@ -728,22 +783,22 @@ if ( open(PIPE, "| $mysqld_install_cmd_l "", "See the manual for more instructions."); } else { - report($opt, - "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !", - "To do so, start the server, then issue the following commands:", - "", - " $bindir/mysqladmin -u root password 'new-password'", - " $bindir/mysqladmin -u root -h $hostname password 'new-password'", - "", - "Alternatively you can run:", - "", - " $bindir/mysql_secure_installation", - "", - "which will also give you the option of removing the test", - "databases and anonymous user created by default. This is", - "strongly recommended for production servers.", - "", - "See the manual for more instructions."); + report($opt, + "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !", + "To do so, start the server, then issue the following commands:", + "", + " $bindir/mysqladmin -u root password 'new-password'", + " $bindir/mysqladmin -u root -h $hostname password 'new-password'", + "", + "Alternatively you can run:", + "", + " $bindir/mysql_secure_installation", + "", + "which will also give you the option of removing the test", + "databases and anonymous user created by default. This is", + "strongly recommended for production servers.", + "", + "See the manual for more instructions."); } if ( !$opt->{rpm} ) @@ -765,6 +820,28 @@ if ( open(PIPE, "| $mysqld_install_cmd_l " http://www.mysql.com", "", "Support MySQL by buying support/licenses at http://shop.mysql.com"); + + if ($copy_cfg_file eq $config_file) + { + report($opt, + "New default config file was created as $config_file and", + "will be used by default by the server when you start it.", + "You may edit this file to change server settings"); + } + else + { + warning($opt, + "Found existing config file $config_file on the system.", + "Because this file might be in use, it was not replaced,", + "but was used in bootstrap (unless you used --defaults-file)", + "and when you later start the server.", + "The new default config file was created as $copy_cfg_file,", + "please compare it with your file and take the changes you need."); + } + foreach my $cfg ( "/etc/my.cnf", "/etc/mysql/my.cnf" ) + { + check_sys_cfg_file ($opt, $cfg); + } } exit 0 } @@ -801,6 +878,21 @@ else # ############################################################################## +sub check_sys_cfg_file +{ + my $opt= shift; + my $fname= shift; + + if ( -e $fname ) + { + warning($opt, + "Default config file $fname exists on the system", + "This file will be read by default by the MySQL server", + "If you do not want to use this, either remove it, or use the", + "--defaults-file argument to mysqld_safe when starting the server"); + } +} + sub report_verbose { my $opt = shift; === modified file 'support-files/CMakeLists.txt' --- a/support-files/CMakeLists.txt 2012-05-23 09:54:40 +0000 +++ b/support-files/CMakeLists.txt 2012-10-10 13:05:43 +0000 @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,6 +16,7 @@ IF(WIN32) SET(localstatedir "C:\\\\mysql\\\\data\\\\") SET(ini_file_extension "ini") + SET(CNF_SOCKET_LINE "") ELSE() SET(localstatedir "${MYSQL_DATADIR}") SET(prefix "${CMAKE_INSTALL_PREFIX}") @@ -30,6 +31,7 @@ ELSE() SET(MYSQLD_USER "mysql") SET(ini_file_extension "cnf") SET(HOSTNAME "hostname") + SET(CNF_SOCKET_LINE "# socket = .....") ENDIF() SET(dictionary "${CMAKE_INSTALL_PREFIX}/${INSTALL_SHAREDIR}/dictionary.txt" ) @@ -42,12 +44,11 @@ ELSE() SET(inst_location ${INSTALL_SUPPORTFILESDIR}) ENDIF() -FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh - ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} - DESTINATION ${inst_location} COMPONENT IniFiles) -ENDFOREACH() +SET(inifile my-default) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh + ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} + DESTINATION ${inst_location} COMPONENT IniFiles) IF(UNIX) SET(prefix ${CMAKE_INSTALL_PREFIX}) === modified file 'support-files/mysql.spec.sh' --- a/support-files/mysql.spec.sh 2012-10-05 15:04:43 +0000 +++ b/support-files/mysql.spec.sh 2012-10-10 13:05:43 +0000 @@ -988,7 +988,7 @@ echo "=====" %doc %{src_dir}/Docs/ChangeLog %doc %{src_dir}/Docs/INFO_SRC* %doc release/Docs/INFO_BIN* -%doc release/support-files/my-*.cnf +%doc release/support-files/my-default.cnf %doc %attr(644, root, root) %{_infodir}/mysql.info* @@ -1149,6 +1149,10 @@ echo "=====" # merging BK trees) ############################################################################## %changelog +* Wed Oct 10 2012 Bjorn Munch + +- Replace old my-*.cnf config file examples with template my-default.cnf + * Fri Oct 05 2012 Joerg Bruehe - Let the installation use the new option "--random-passwords" of "mysql_install_db". No bundle (reason: useless for push emails).