diff --git a/Makefile.am b/Makefile.am index c1bdbb22e8e..52a9dcbd389 100644 --- a/Makefile.am +++ b/Makefile.am @@ -102,7 +102,7 @@ dist-hook: rm -rf `find $(distdir) -type d -name SCCS -print` rm -f `find $(distdir) -type l -print` mkdir -p $(distdir)/win - scripts/mysql_install_db --no-defaults --windows \ + scripts/mysql_install_db --no-defaults --cross-bootstrap \ --basedir=$(top_builddir) \ --datadir=$(distdir)/win/data \ --srcdir=$(top_srcdir) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 5716d4f51c0..5d925a0b8ad 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -30,13 +30,15 @@ user="" force=0 in_rpm=0 ip_only=0 -windows=0 +cross_bootstrap=0 usage() { cat <&1` if [ $? -ne 0 ] @@ -329,6 +330,16 @@ then args="$args --user=$user" fi +# When doing a "cross bootstrap" install, no reference to the current +# host should be added to the system tables. So we filter out any +# lines which contain the current host name. +if test $cross_bootstrap -eq 1 +then + filter_cmd_line="sed -e '/@current_hostname/d'" +else + filter_cmd_line="cat" +fi + # Peform the install of system tables mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}" mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \ @@ -337,15 +348,14 @@ mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \ # Pipe mysql_system_tables.sql to "mysqld --bootstrap" s_echo "Installing MySQL system tables..." -if `(echo "use mysql;"; cat $create_system_tables $fill_system_tables) | $mysqld_install_cmd_line` +if { echo "use mysql;"; cat $create_system_tables $fill_system_tables; } | eval "$filter_cmd_line" | $mysqld_install_cmd_line > /dev/null then s_echo "OK" s_echo "Filling help tables..." # Pipe fill_help_tables.sql to "mysqld --bootstrap" - if `(echo "use mysql;"; cat $fill_help_tables) | $mysqld_install_cmd_line` + if { echo "use mysql;"; cat $fill_help_tables; } | $mysqld_install_cmd_line > /dev/null then - # Fill suceeded s_echo "OK" else echo @@ -359,14 +369,12 @@ then s_echo "support-files/mysql.server to the right place for your system" s_echo - if test "$windows" -eq 0 + if test "$cross_bootstrap" -eq 0 then - # A root password should of course also be set on Windows! - # The reason for not displaying these prompts here is that when - # executing this script with the --windows argument the script - # is used to generate system tables mainly used by the - # windows installer. And thus the password should not be set until - # those files has been copied to the target system + # This is not a true installation on a running system. The end user must + # set a password after installing the data files on the real host system. + # At this point, there is no end user, so it does not make sense to print + # this reminder. echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !" echo "To do so, start the server, then issue the following commands:" echo "$bindir/mysqladmin -u root password 'new-password'" diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql index 47d4ea5d950..ce23953a1a5 100644 --- a/scripts/mysql_system_tables_data.sql +++ b/scripts/mysql_system_tables_data.sql @@ -2,6 +2,12 @@ -- The inital data for system tables of MySQL Server -- +-- When setting up a "cross bootstrap" database (e.g., creating data on a Unix +-- host which will later be included in a Windows zip file), any lines +-- containing "@current_hostname" are filtered out by mysql_install_db. +set @current_hostname= @@hostname; + + -- Fill "db" table with default grants for anyone to -- access database 'test' and 'test_%' if "db" table didn't exist CREATE TEMPORARY TABLE tmp_db LIKE db; @@ -15,10 +21,9 @@ DROP TABLE tmp_db; -- from local machine if "users" table didn't exist before CREATE TEMPORARY TABLE tmp_user LIKE user; INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); -set @hostname= @@hostname; -REPLACE INTO tmp_user VALUES (@hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); +REPLACE INTO tmp_user VALUES (@current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); INSERT INTO tmp_user (host,user) VALUES ('localhost',''); -INSERT INTO tmp_user (host,user) VALUES (@@hostname,''); +INSERT INTO tmp_user (host,user) VALUES (@current_hostname,''); INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0; DROP TABLE tmp_user;