aedd719
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
aedd719
index 440a977..7d068fc 100644
aedd719
--- a/scripts/mysql_install_db.pl.in
aedd719
+++ b/scripts/mysql_install_db.pl.in
aedd719
@@ -75,6 +97,8 @@ Usage: $0 [OPTIONS]
aedd719
   --help               Display this help and exit.                     
aedd719
   --ldata=path         The path to the MySQL data directory. Same as --datadir.
aedd719
   --no-defaults        Don't read default options from any option file.
aedd719
+  --keep-my-cnf        Don't try to create my.cnf based on template. 
aedd719
+                       Useful for systems with working, updated my.cnf.
aedd719
 EOF1
aedd719
   if ( $^O !~ m/^(MSWin32|cygwin)$/ ) {
aedd719
     print <
aedd719
@@ -86,6 +110,7 @@ EOF2
aedd719
   print <
aedd719
   --rpm                For internal use.  This option is used by RPM files
aedd719
                        during the MySQL installation process.
aedd719
+                       Implies --keep-my-cnf option.
aedd719
   --skip-name-resolve  Use IP addresses rather than hostnames when creating
aedd719
                        grant table entries.  This option can be useful if
aedd719
                        your DNS does not work.
aedd719
@@ -149,6 +174,7 @@ sub parse_arguments
aedd719
 
aedd719
              "skip-name-resolve",
aedd719
              "verbose",
aedd719
+             "keep-my-cnf",
aedd719
              "rpm",
aedd719
              "help",
aedd719
              "random-passwords",
aedd719
@@ -399,11 +431,16 @@ $basedir= "@prefix@" if ! $basedir;		# Default
aedd719
 # ----------------------------------------------------------------------
aedd719
 
aedd719
 my $print_defaults;
aedd719
+my $keep_my_cnf = 0;
aedd719
 
aedd719
 if ( $opt->{srcdir} and $opt->{basedir} )
aedd719
 {
aedd719
   error($opt,"Specify either --basedir or --srcdir, not both");
aedd719
 }
aedd719
+if ( $opt->{rpm} || $opt->{'keep-my-cnf'} )
aedd719
+{
aedd719
+  $keep_my_cnf = 1;
aedd719
+}
aedd719
 if ( $opt->{srcdir} )
aedd719
 {
aedd719
   $opt->{builddir} = $opt->{srcdir} unless $opt->{builddir};
Bjorn Munch 5f2a76b
@@ -425,7 +462,7 @@ my $config_file;
aedd719
 my $copy_cfg_file;
aedd719
 
aedd719
 # ----------------------------------------------------------------------
aedd719
-# This will be the default config file
aedd719
+# This will be the default config file (unless creation is unwanted)
aedd719
 # ----------------------------------------------------------------------
aedd719
 
Bjorn Munch 5f2a76b
 my $cnfext = ( $^O =~ m/^(MSWin32|cygwin)$/ ) ? "ini" : "cnf";
Bjorn Munch 5f2a76b
@@ -434,6 +471,11 @@ $config_file= "$basedir/my.$cnfext";
aedd719
 
Bjorn Munch 5f2a76b
 my $cfg_template= find_in_basedir($opt,"file","my-default.$cnfext",
Bjorn Munch 5f2a76b
 				  ".", "share","share/mysql","support-files");
aedd719
+# Distros might move files
aedd719
+if ((! -r $cfg_template) && (-r "@pkgdatadir@/my-default.cnf")) {
aedd719
+  $cfg_template = "@pkgdatadir@/my-default.cnf";
aedd719
+}
aedd719
+
Bjorn Munch 5f2a76b
 -e $cfg_template or cannot_find_file("my-default.$cnfext");
aedd719
 
aedd719
 $copy_cfg_file= $config_file;
Bjorn Munch 5f2a76b
@@ -443,22 +485,21 @@ if (-e $copy_cfg_file)
Bjorn Munch 5f2a76b
   $copy_cfg_file =~ s/my.$cnfext/my-new.$cnfext/;
aedd719
   # Too early to print warning here, the user may not notice
aedd719
 }
aedd719
-open (TEMPL, $cfg_template) or error($opt, "Could not open config template $cfg_template");
aedd719
-if (open (CFG, "> $copy_cfg_file"))
aedd719
-{
aedd719
-  while (<TEMPL>)
aedd719
-  {
aedd719
-    # Remove lines beginning with # *** which are template comments
aedd719
-    print CFG $_ unless /^# \*\*\*/;
aedd719
+
aedd719
+if ( ! $keep_my_cnf ) {
aedd719
+  open (TEMPL, $cfg_template) or error($opt, "Could not open config template $cfg_template");
aedd719
+  if (open (CFG, "> $copy_cfg_file")) {
aedd719
+    while (<TEMPL>) {
aedd719
+      # Remove lines beginning with # *** which are template comments
aedd719
+      print CFG $_ unless /^# \*\*\*/;
aedd719
+    }
aedd719
+    close CFG;
aedd719
+  } else {
aedd719
+    warning($opt,"Could not write to config file $copy_cfg_file: $!");
aedd719
+    $failed_write_cfg= 1;
aedd719
   }
aedd719
-  close CFG;
aedd719
+  close TEMPL;
aedd719
 }
aedd719
-else
aedd719
-{
aedd719
-  warning($opt,"Could not write to config file $copy_cfg_file: $!");
aedd719
-  $failed_write_cfg= 1;
aedd719
-}
aedd719
-close TEMPL;
aedd719
 
aedd719
 # ----------------------------------------------------------------------
aedd719
 # Now we can get arguments from the groups [mysqld] and [mysql_install_db]
Bjorn Munch 5f2a76b
@@ -621,7 +662,7 @@ if ( $opt->{'skip-name-resolve'} and $resolved and $resolved =~ /\s/ )
aedd719
 }
aedd719
 
aedd719
 # ----------------------------------------------------------------------
aedd719
-# Create database directories mysql & test
aedd719
+# Create database directory mysql
aedd719
 # ----------------------------------------------------------------------
aedd719
 
aedd719
 # FIXME The shell variant uses "mkdir -p":
Bjorn Munch 5f2a76b
@@ -654,7 +695,7 @@ if ($opt_user)
aedd719
   }
aedd719
 }
aedd719
 
aedd719
-foreach my $dir ( $opt->{ldata}, "$opt->{ldata}/mysql", "$opt->{ldata}/test" )
aedd719
+foreach my $dir ( $opt->{ldata}, "$opt->{ldata}/mysql")
aedd719
 {
aedd719
   mkdir($dir, 0700) unless -d $dir;
aedd719
   if ($opt_user and -w "/")
Bjorn Munch 5f2a76b
@@ -848,7 +889,13 @@ if ( open(PIPE, "| $mysqld_install_cmd_line") )
aedd719
            "",
aedd719
            "Support MySQL by buying support/licenses at http://shop.mysql.com");
aedd719
 
aedd719
-    if ($copy_cfg_file eq $config_file and !$failed_write_cfg)
aedd719
+    if ($keep_my_cnf)
aedd719
+    {
aedd719
+      report($opt,
aedd719
+	     "Note: new default config file not created.",
aedd719
+	     "Please make sure your config file is current");
aedd719
+    }
aedd719
+    elsif ($copy_cfg_file eq $config_file and !$failed_write_cfg)
aedd719
     {
aedd719
       report($opt,
aedd719
 	     "New default config file was created as $config_file and",