mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
5d4e0417ad
- Use mysql_system_tables.sql to create MySQL system tables in all places where we create them(mysql_install_db, mysql-test-run-pl and mysql_fix_privilege_tables.sql) BitKeeper/deleted/.del-init_db.sql: Rename: mysql-test/init_db.sql -> BitKeeper/deleted/.del-init_db.sql BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8: Rename: mysql-test/lib/init_db.sql -> BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8 BitKeeper/deleted/.del-mysql_create_system_tables.sh: Rename: scripts/mysql_create_system_tables.sh -> BitKeeper/deleted/.del-mysql_create_system_tables.sh BitKeeper/etc/ignore: Added scripts/mysql_fix_privilege_tables.sql to the ignore list mysql-test/Makefile.am: lib/init_db.sql has been removed mysql-test/mysql-test-run.pl: - Build var/tmp/bootstrap.sql from mysql_system_tables.sql, mysql_test_data_timezone.sql and fill_help_tables.sql and use it when bootsraping the system tables to use during test. mysql-test/r/create.result: Update result file mysql-test/r/derived.result: Update result file mysql-test/r/join.result: Update result file mysql-test/r/mysql_upgrade.result: Update result file mysql-test/r/sp-security.result: Update result file mysql-test/t/create.test: Add user mysqltest_1 before trying to connect as that user - no anon users by default anymore mysql-test/t/derived.test: Add user mysqltest_1 before trying to connect as that user - no anon users by default anymore mysql-test/t/grant2.test: Add anonymous users for part of thes that need it. mysql-test/t/grant_cache.test: Add anonymous users for part of thes that need it. mysql-test/t/init_connect.test: Add anonymous users for part of thes that need it. mysql-test/t/lock_multi.test: Add anonymous users for part of thes that need it. mysql-test/t/ndb_basic.test: Connect as "root", blank user will take currently logged in username mysql-test/t/ndb_index_ordered.test: Connect as "root", blank user will take currently logged in username mysql-test/t/ndb_multi.test: Connect as "root", blank user will take currently logged in username mysql-test/t/overflow.test: Connect as root - no anonymous users by default anymore mysql-test/t/rpl_temporary.test: Add anonymous users for the test mysql-test/t/xa.test: Connect as "root", blank user wil pick currently logged in user scripts/Makefile.am: Remove mysql_create_system_tables.sh Add mysql_system_tables.sql and mysql_test_data_timezone.sql Build mysql_fix_privilege_tables.sql from mysql_system_tables.sql and mysql_fix_privilege_tables.sql.in scripts/mysql_fix_privilege_tables.sh: Update message describing what the script does scripts/mysql_fix_privilege_tables.sql.in: Remove the part that creates system tables as that will be added to mysql_fix_privileg_tables.sql from mysql_system_tables.sql Change all comments to use # scripts/mysql_install_db.sh: Use mysql_system_tables.sql to create the MySQL system tables Update comments and indentation Add more descriptive comments about --windows switch Reduce number of hardcoded names for the SQL files the script looks for mysql-test/include/add_anonymous_users.inc: New BitKeeper file ``mysql-test/include/add_anonymous_users.inc'' mysql-test/include/delete_anonymous_users.inc: New BitKeeper file ``mysql-test/include/delete_anonymous_users.inc'' scripts/mysql_system_tables.sql: New BitKeeper file ``scripts/mysql_system_tables.sql'' scripts/mysql_test_data_timezone.sql: New BitKeeper file ``scripts/mysql_test_data_timezone.sql''
222 lines
5.6 KiB
Bash
222 lines
5.6 KiB
Bash
#!/bin/sh
|
|
# Copyright (C) 2000-2006 MySQL AB
|
|
#
|
|
# 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
|
|
# the Free Software Foundation; version 2 of the License.
|
|
#
|
|
# 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 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
|
|
|
|
# This script is a wrapper to pipe the mysql_fix_privilege_tables.sql
|
|
# through the mysql client program to the mysqld server
|
|
|
|
# Default values (Can be changed in my.cnf)
|
|
password=""
|
|
host="localhost"
|
|
user="root"
|
|
sql_only=0
|
|
basedir="@prefix@"
|
|
verbose=0
|
|
args=""
|
|
port=""
|
|
socket=""
|
|
database="mysql"
|
|
bindir=""
|
|
pkgdatadir="@pkgdatadir@"
|
|
print_defaults_bindir="."
|
|
|
|
file=mysql_fix_privilege_tables.sql
|
|
|
|
# The following test is to make this script compatible with the 4.0 where
|
|
# the single argument could be a password
|
|
if test "$#" = 1
|
|
then
|
|
case "$1" in
|
|
--*) ;;
|
|
*) old_style_password="$1" ; shift ;;
|
|
esac
|
|
fi
|
|
|
|
# The following code is almost identical to the code in mysql_install_db.sh
|
|
|
|
case "$1" in
|
|
--no-defaults|--defaults-file=*|--defaults-extra-file=*)
|
|
defaults="$1"; shift
|
|
;;
|
|
esac
|
|
|
|
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
|
|
case "$arg" in
|
|
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
|
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
|
--password=*) password=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
|
--host=*) host=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
|
--sql|--sql-only) sql_only=1 ;;
|
|
--verbose) verbose=1 ;;
|
|
--port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;;
|
|
--socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;;
|
|
--database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;;
|
|
--bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"`
|
|
print_defaults_bindir=$bindir
|
|
;;
|
|
*)
|
|
if test -n "$pick_args"
|
|
then
|
|
# This sed command makes sure that any special chars are quoted,
|
|
# so the arg gets passed exactly to the server.
|
|
args="$args "`echo "$arg" | sed -e 's,\([^=a-zA-Z0-9_.-]\),\\\\\1,g'`
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
# Get first arguments from the my.cfg file, groups [mysqld] and
|
|
# [mysql_install_db], and then merge with the command line arguments
|
|
|
|
print_defaults=my_print_defaults
|
|
for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
|
|
do
|
|
if test -x $dir/my_print_defaults
|
|
then
|
|
print_defaults="$dir/my_print_defaults"
|
|
break
|
|
fi
|
|
done
|
|
|
|
parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
|
|
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
|
|
|
if test -z "$password"
|
|
then
|
|
password=$old_style_password
|
|
fi
|
|
|
|
# Find where 'mysql' command is located
|
|
|
|
dirname=`dirname "$0"`
|
|
|
|
if test -z "$bindir"
|
|
then
|
|
for i in @bindir@ $basedir/bin "$dirname/../client"
|
|
do
|
|
if test -f $i/mysql
|
|
then
|
|
bindir=$i
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if test -z "$bindir"
|
|
then
|
|
echo "Could not find MySQL command-line client (mysql)."
|
|
echo "Please use --basedir to specify the directory where MySQL is installed."
|
|
exit 1
|
|
fi
|
|
|
|
cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
|
|
if test ! -z "$port"; then
|
|
cmd="$cmd --port=$port"
|
|
fi
|
|
if test ! -z "$socket"; then
|
|
cmd="$cmd --socket=$socket"
|
|
fi
|
|
cmd="$cmd --database=$database"
|
|
|
|
if test $sql_only = 1
|
|
then
|
|
cmd="cat"
|
|
fi
|
|
|
|
# Find where first mysql_fix_privilege_tables.sql is located
|
|
for i in $basedir/support-files $basedir/share $basedir/share/mysql \
|
|
$basedir/scripts $pkgdatadir . "$dirname"
|
|
do
|
|
if test -f $i/$file
|
|
then
|
|
pkgdatadir=$i
|
|
break
|
|
fi
|
|
done
|
|
|
|
sql_file="$pkgdatadir/$file"
|
|
if test ! -f $sql_file
|
|
then
|
|
echo "Could not find file '$file'."
|
|
echo "Please use --basedir to specify the directory where MySQL is installed"
|
|
exit 1
|
|
fi
|
|
|
|
s_echo()
|
|
{
|
|
if test $sql_only = 0
|
|
then
|
|
echo $1
|
|
fi
|
|
}
|
|
|
|
s_echo "This script updates all the mysql privilege tables to be usable by"
|
|
s_echo "the current version of MySQL"
|
|
s_echo ""
|
|
|
|
if test $verbose = 1
|
|
then
|
|
s_echo "You can safely ignore all 'Duplicate column' and 'Unknown column' errors"
|
|
s_echo "because these just mean that your tables are already up to date."
|
|
s_echo "This script is safe to run even if your tables are already up to date!"
|
|
s_echo ""
|
|
fi
|
|
|
|
run_cmd() {
|
|
# Password argument is added here to allow for spaces in password.
|
|
|
|
if test ! -z "$password"
|
|
then
|
|
cat $sql_file | $cmd --password="$password"
|
|
else
|
|
cat $sql_file | $cmd
|
|
fi
|
|
}
|
|
|
|
if test $verbose = 0
|
|
then
|
|
run_cmd > /dev/null 2>&1
|
|
else
|
|
run_cmd > /dev/null
|
|
fi
|
|
if test $? = 0
|
|
then
|
|
s_echo "done"
|
|
else
|
|
s_echo "Got a failure from command:"
|
|
s_echo "cat $sql_file | $cmd"
|
|
s_echo "Please check the above output and try again."
|
|
if test $verbose = 0
|
|
then
|
|
s_echo ""
|
|
s_echo "Running the script with the --verbose option may give you some information"
|
|
s_echo "of what went wrong."
|
|
fi
|
|
s_echo ""
|
|
s_echo "If you get an 'Access denied' error, you should run this script again and"
|
|
s_echo "give the MySQL root user password as an argument with the --password= option"
|
|
fi
|