summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/CMakeLists.txt2
-rw-r--r--scripts/Makefile.am6
-rw-r--r--scripts/make_binary_distribution.sh8
-rwxr-xr-xscripts/make_win_bin_dist93
-rw-r--r--scripts/make_win_src_distribution_old.sh (renamed from scripts/make_win_src_distribution.sh)8
-rw-r--r--scripts/mysql_install_db.sh342
-rw-r--r--scripts/mysql_setpermission.sh22
-rw-r--r--scripts/mysqlhotcopy.sh32
8 files changed, 268 insertions, 245 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index e9113b098da..6fbfcab72d4 100755
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -24,7 +24,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tabl
# Build comp_sql - used for embedding SQL in C or C++ programs
ADD_EXECUTABLE(comp_sql comp_sql.c)
-TARGET_LINK_LIBRARIES(comp_sql dbug mysys strings)
+TARGET_LINK_LIBRARIES(comp_sql debug dbug mysys strings)
# Use comp_sql to build mysql_fix_privilege_tables_sql.c
GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION)
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 2b6870717ba..182076b32b6 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -41,11 +41,11 @@ bin_SCRIPTS = @server_scripts@ \
noinst_SCRIPTS = make_binary_distribution \
make_sharedlib_distribution \
- make_win_src_distribution
+ make_win_src_distribution_old
EXTRA_SCRIPTS = make_binary_distribution.sh \
make_sharedlib_distribution.sh \
- make_win_src_distribution.sh \
+ make_win_src_distribution_old.sh \
msql2mysql.sh \
mysql_config.sh \
mysql_fix_privilege_tables.sh \
@@ -99,7 +99,7 @@ CLEANFILES = @server_scripts@ \
mysql_tableinfo \
mysql_upgrade_shell \
mysqld_multi \
- make_win_src_distribution
+ make_win_src_distribution_old
# mysqlbug should be distributed built so that people can report build
# failures with it.
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 77f51c51c19..a87bb03526d 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -257,7 +257,7 @@ if [ $BASE_SYSTEM = "netware" ] ; then
rm -f $BASE/lib/*.la
fi
-copyfileto $BASE/include config.h include/*
+copyfileto $BASE/include include/*
rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
if [ $BASE_SYSTEM != "netware" ] ; then
@@ -284,7 +284,8 @@ rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
copyfileto $BASE/mysql-test \
mysql-test/mysql-test-run mysql-test/install_test_db \
mysql-test/mysql-test-run.pl mysql-test/README \
- mysql-test/valgrind.supp \
+ mysql-test/mysql-stress-test.pl \
+ mysql-test/valgrind.supp \
netware/mysql_test_run.nlm netware/install_test_db.ncf
$CP mysql-test/lib/*.pl $BASE/mysql-test/lib
@@ -295,6 +296,7 @@ $CP mysql-test/t/*.def $BASE/mysql-test/t
$CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
mysql-test/std_data/*.MYD mysql-test/std_data/*.MYI \
mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \
+ mysql-test/std_data/Index.xml \
mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \
mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \
$BASE/mysql-test/std_data
@@ -316,7 +318,7 @@ if [ $BASE_SYSTEM != "netware" ] ; then
copyfileto $BASE/bin scripts/*
$BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ \
./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ \
- @HOSTNAME@ \@pkgdatadir\@ ./support-files \
+ @HOSTNAME@ \@pkgdatadir\@ ./share \
< scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
$BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \
\@sbindir\@ ./bin \@libexecdir\@ ./bin \
diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist
index beb274ca1a3..849226c94ea 100755
--- a/scripts/make_win_bin_dist
+++ b/scripts/make_win_bin_dist
@@ -144,14 +144,16 @@ fi
mkdir $DESTDIR
mkdir $DESTDIR/bin
-cp client/$TARGET/*.exe $DESTDIR/bin/
-cp extra/$TARGET/*.exe $DESTDIR/bin/
-cp myisam/$TARGET/*.exe $DESTDIR/bin/
-cp server-tools/instance-manager/$TARGET/*.exe $DESTDIR/bin/
-cp server-tools/instance-manager/$TARGET/*.pdb $DESTDIR/bin/ || true
-cp server-tools/instance-manager/$TARGET/*.map $DESTDIR/bin/ || true
-cp tests/$TARGET/*.exe $DESTDIR/bin/
-cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/
+cp client/$TARGET/*.exe $DESTDIR/bin/
+cp extra/$TARGET/*.exe $DESTDIR/bin/
+cp myisam/$TARGET/*.exe $DESTDIR/bin/
+cp server-tools/instance-manager/$TARGET/*.{exe,map} $DESTDIR/bin/
+if [ x"$TARGET" != x"release" ] ; then
+ cp server-tools/instance-manager/$TARGET/*.pdb $DESTDIR/bin/
+fi
+cp tests/$TARGET/*.exe $DESTDIR/bin/
+cp libmysql/$TARGET/*.exe $DESTDIR/bin/
+cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/
# FIXME really needed?!
mv $DESTDIR/bin/comp_err.exe $DESTDIR/bin/comp-err.exe
@@ -164,8 +166,10 @@ fi
# Depending on Visual Studio target, the optimized server has symbols
cp sql/$TARGET/$BASENAME.exe $DESTDIR/bin/$BASENAME$EXE_SUFFIX.exe
-cp sql/$TARGET/$BASENAME.pdb $DESTDIR/bin/$BASENAME$EXE_SUFFIX.pdb || true
-cp sql/$TARGET/$BASENAME.map $DESTDIR/bin/$BASENAME$EXE_SUFFIX.map || true
+cp sql/$TARGET/$BASENAME.map $DESTDIR/bin/$BASENAME$EXE_SUFFIX.map
+if [ x"$TARGET" != x"release" ] ; then
+ cp sql/$TARGET/$BASENAME.pdb $DESTDIR/bin/$BASENAME$EXE_SUFFIX.pdb
+fi
if [ -f "sql/debug/mysqld-debug.exe" ] ; then
BASENAME="mysqld-debug" # Old style non CMake build
@@ -176,19 +180,16 @@ fi
if [ x"$PACK_DEBUG" = x"" -a -f "sql/debug/$BASENAME.exe" -o \
x"$PACK_DEBUG" = x"yes" ] ; then
cp sql/debug/$BASENAME.exe $DESTDIR/bin/mysqld-debug.exe
- cp sql/debug/$BASENAME.pdb $DESTDIR/bin/mysqld-debug.pdb || true
- cp sql/debug/$BASENAME.map $DESTDIR/bin/mysqld-debug.map || true
+ cp sql/debug/$BASENAME.pdb $DESTDIR/bin/mysqld-debug.pdb
+ cp sql/debug/$BASENAME.map $DESTDIR/bin/mysqld-debug.map
fi
# ----------------------------------------------------------------------
# Copy data directory, readme files etc
# ----------------------------------------------------------------------
-# FIXME is there ever a data directory to copy?
if [ -d win/data ] ; then
cp -pR win/data $DESTDIR/
-elif [ -d data ] ; then
- cp -pR data $DESTDIR/
fi
# FIXME maybe a flag to define "release build", or do the
@@ -218,16 +219,22 @@ copy_embedded()
$DESTDIR/include
cp libmysqld/libmysqld.def $DESTDIR/include/
cp libmysqld/$TARGET/mysqlserver.lib $DESTDIR/Embedded/static/release/
+ cp libmysqld/$TARGET/mysqlserver.pdb $DESTDIR/Embedded/static/release/
cp libmysqld/$TARGET/libmysqld.dll $DESTDIR/Embedded/DLL/release/
cp libmysqld/$TARGET/libmysqld.exp $DESTDIR/Embedded/DLL/release/
cp libmysqld/$TARGET/libmysqld.lib $DESTDIR/Embedded/DLL/release/
+ cp libmysqld/$TARGET/libmysqld.pdb $DESTDIR/Embedded/DLL/release/
if [ x"$PACK_DEBUG" = x"" -a -f "libmysqld/debug/libmysqld.lib" -o \
x"$PACK_DEBUG" = x"yes" ] ; then
- mkdir -p $DESTDIR/Embedded/DLL/debug
+ mkdir -p $DESTDIR/Embedded/DLL/debug \
+ $DESTDIR/Embedded/static/debug
+ cp libmysqld/debug/mysqlserver.lib $DESTDIR/Embedded/static/debug/
+ cp libmysqld/debug/mysqlserver.pdb $DESTDIR/Embedded/static/debug/
cp libmysqld/debug/libmysqld.dll $DESTDIR/Embedded/DLL/debug/
cp libmysqld/debug/libmysqld.exp $DESTDIR/Embedded/DLL/debug/
cp libmysqld/debug/libmysqld.lib $DESTDIR/Embedded/DLL/debug/
+ cp libmysqld/debug/libmysqld.pdb $DESTDIR/Embedded/DLL/debug/
fi
}
@@ -287,7 +294,8 @@ cp include/mysql.h \
mkdir -p $DESTDIR/lib/opt
cp libmysql/$TARGET/libmysql.dll \
libmysql/$TARGET/libmysql.lib \
- client/$TARGET/mysqlclient.lib \
+ libmysql/$TARGET/mysqlclient.lib \
+ mysys/$TARGET/mysys.lib \
regex/$TARGET/regex.lib \
strings/$TARGET/strings.lib \
zlib/$TARGET/zlib.lib $DESTDIR/lib/opt/
@@ -297,54 +305,25 @@ if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/libmysql.lib" -o \
mkdir -p $DESTDIR/lib/debug
cp libmysql/debug/libmysql.dll \
libmysql/debug/libmysql.lib \
- client/debug/mysqlclient.lib \
+ libmysql/debug/mysqlclient.lib \
+ mysys/debug/mysys.lib \
regex/debug/regex.lib \
strings/debug/strings.lib \
zlib/debug/zlib.lib $DESTDIR/lib/debug/
-
- if [ -f "mysys/debug/mysys-nt.lib" ] ; then
- cp mysys/debug/mysys-nt.lib $DESTDIR/lib/debug/
- else
- cp mysys/debug/mysys.lib $DESTDIR/lib/debug/mysys-nt.lib
- fi
-
-fi
-
-if [ -f "mysys/$TARGET/mysys-nt.lib" ] ; then
- cp mysys/$TARGET/mysys-nt.lib $DESTDIR/lib/opt/
-else
- cp mysys/$TARGET/mysys.lib $DESTDIR/lib/opt/mysys-nt.lib
fi
# ----------------------------------------------------------------------
# Copy the test directory
# ----------------------------------------------------------------------
-mkdir -p $DESTDIR/mysql-test/include $DESTDIR/mysql-test/lib \
- $DESTDIR/mysql-test/r $DESTDIR/mysql-test/std_data \
- $DESTDIR/mysql-test/t
+mkdir $DESTDIR/mysql-test
cp mysql-test/mysql-test-run.pl $DESTDIR/mysql-test/
cp mysql-test/README $DESTDIR/mysql-test/
-cp mysql-test/install_test_db.sh $DESTDIR/mysql-test/install_test_db
-cp mysql-test/include/*.inc $DESTDIR/mysql-test/include/
-cp mysql-test/include/*.test $DESTDIR/mysql-test/include/
-cp mysql-test/lib/*.pl $DESTDIR/mysql-test/lib/
-cp mysql-test/lib/*.sql $DESTDIR/mysql-test/lib/ || true
-cp mysql-test/r/*.require $DESTDIR/mysql-test/r/
-# Need this trick, or we get "argument list too long".
-ABS_DST=`pwd`/$DESTDIR
-(cd mysql-test/r/ && cp *.result $ABS_DST/mysql-test/r/)
-cp mysql-test/std_data/* $DESTDIR/mysql-test/std_data/
-cp mysql-test/t/*.opt $DESTDIR/mysql-test/t/
-cp mysql-test/t/*.sh $DESTDIR/mysql-test/t/
-cp mysql-test/t/*.slave-mi $DESTDIR/mysql-test/t/
-cp mysql-test/t/*.sql $DESTDIR/mysql-test/t/
-cp mysql-test/t/*.def $DESTDIR/mysql-test/t/
-(cd mysql-test/t/ && cp *.test $ABS_DST/mysql-test/t/)
+cp -R mysql-test/{t,r,include,suite,std_data,lib} $DESTDIR/mysql-test/
# Note that this will not copy "extra" if a soft link
if [ -d mysql-test/extra ] ; then
- mkdir -p $DESTDIR/mysql-test/extra
+ mkdir $DESTDIR/mysql-test/extra
cp -pR mysql-test/extra/* $DESTDIR/mysql-test/extra/
fi
@@ -372,11 +351,7 @@ for i in `cd scripts && ls`; do \
fi; \
done
-if [ -d "share" ] ; then
- cp -pR share $DESTDIR/
-else
- cp -pR sql/share $DESTDIR/
-fi
+cp -pR sql/share $DESTDIR/
cp -pR sql-bench $DESTDIR/
rm -f $DESTDIR/sql-bench/*.sh $DESTDIR/sql-bench/Makefile*
@@ -384,6 +359,12 @@ rm -f $DESTDIR/sql-bench/*.sh $DESTDIR/sql-bench/Makefile*
mv $DESTDIR/scripts/*.sql $DESTDIR/share/ || true
# ----------------------------------------------------------------------
+# Clean up from possibly copied SCCS directories
+# ----------------------------------------------------------------------
+
+rm -rf `find $DISTDIR -type d -name SCCS -print`
+
+# ----------------------------------------------------------------------
# Copy other files specified on command line DEST=SOURCE
# ----------------------------------------------------------------------
diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution_old.sh
index d6109772060..dfb43585a21 100644
--- a/scripts/make_win_src_distribution.sh
+++ b/scripts/make_win_src_distribution_old.sh
@@ -14,6 +14,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+# NOTE: This script creates a source TAR and ZIP to be used when
+# building using Visual Studio 2003 .Net. To gain more flexibility, a
+# new CMake build was added. The new build obsoletes this script, Unix
+# and Windows share the same source TAR/ZIP.
+# Also note that the old build from source created by this script is
+# no longer tested by MySQL AB and may not work. Please use the new
+# CMake based build.
+
# Terminate loudly on error, we don't want partial package
set -e
trap "echo '*** script failed ***'" 0
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 934d245db15..a66129af1d3 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -18,26 +18,68 @@
#
# All unrecognized arguments to this script are passed to mysqld.
-in_rpm=0
-windows=0
+basedir=""
+ldata=""
+srcdir=""
+
+args=""
defaults=""
+mysqld_opt=""
user=""
-case "$1" in
- --no-defaults|--defaults-file=*|--defaults-extra-file=*)
- defaults="$1"; shift
- ;;
-esac
+force=0
+in_rpm=0
+ip_only=0
+windows=0
+
+usage()
+{
+ cat <<EOF
+Usage: $0 [OPTIONS]
+ --basedir=path The path to the MySQL installation directory.
+ --datadir=path The path to the MySQL data directory.
+ --force Causes mysql_install_db to run even if DNS does not
+ work. In that case, grant table entries that normally
+ use hostnames will use IP addresses.
+ --ldata=path The path to the MySQL data directory.
+ --rpm For internal use. This option is used by RPM files
+ during the MySQL installation process.
+ --skip-name-resolve Use IP addresses rather than hostnames when creating
+ grant table entries. This option can be useful if
+ your DNS does not work.
+ --srcdir=path For internal use. The directory under which
+ mysql_install_db looks for support files such as the
+ error message file and the file for popoulating the
+ help tables.
+ --user=user_name The login username to use for running mysqld. Files
+ and directories created by mysqld will be owned by this
+ user. You must be root to use this option. By default
+ mysqld runs using your current login name and files and
+ directories that it creates will be owned by you.
+ --windows For internal use. This option is used for creating
+ Windows distributions.
+
+All other options are passed to the mysqld program
+
+EOF
+ exit 1
+}
s_echo()
{
if test "$in_rpm" -eq 0 -a "$windows" -eq 0
then
- echo $1
+ echo "$1"
fi
}
-parse_arguments() {
+parse_arg()
+{
+ echo "$1" | sed -e 's/^[^=]*=//'
+}
+
+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.
@@ -48,20 +90,24 @@ parse_arguments() {
shift
fi
- for arg do
+ for arg
+ do
case "$arg" in
--force) force=1 ;;
- --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
- --srcdir=*) srcdir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
- --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
+ --basedir=*) basedir=`parse_arg "$arg"` ;;
+ --srcdir=*) srcdir=`parse_arg "$arg"` ;;
+ --ldata=*|--datadir=*) ldata=`parse_arg "$arg"` ;;
--user=*)
# Note that the user will be passed to mysqld so that it runs
# as 'user' (crucial e.g. if log-bin=/some_other_path/
# where a chown of datadir won't help)
- user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
+ user=`parse_arg "$arg"` ;;
--skip-name-resolve) ip_only=1 ;;
--verbose) verbose=1 ;; # Obsolete
--rpm) in_rpm=1 ;;
+ --help) usage ;;
+ --no-defaults|--defaults-file=*|--defaults-extra-file=*)
+ defaults="$arg" ;;
--windows)
# This is actually a "cross bootstrap" argument used when
@@ -89,137 +135,152 @@ parse_arguments() {
done
}
-# Get first arguments from the my.cfg file, groups [mysqld] and
-# [mysql_install_db], and then merge with the command line arguments
-if test -x ./bin/my_print_defaults
-then
- print_defaults="./bin/my_print_defaults"
-elif test -x ./extra/my_print_defaults
-then
- print_defaults="./extra/my_print_defaults"
-elif test -x @bindir@/my_print_defaults
-then
- print_defaults="@bindir@/my_print_defaults"
-elif test -x @bindir@/mysql_print_defaults
-then
- print_defaults="@bindir@/mysql_print_defaults"
-else
- print_defaults="my_print_defaults"
-fi
+# Try to find a specific file within --basedir which can either be a binary
+# release or installed source directory and return the path.
+find_in_basedir()
+{
+ case "$1" in
+ --dir)
+ return_dir=1; shift
+ ;;
+ esac
-args=
-ldata=
-execdir=
-bindir=
-basedir=
-srcdir=
-force=0
+ file=$1; shift
-parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
+ for dir in "$@"
+ do
+ if test -f "$basedir/$dir/$file"
+ then
+ if test -n "$return_dir"
+ then
+ echo "$basedir/$dir"
+ else
+ echo "$basedir/$dir/$file"
+ fi
+ break
+ fi
+ done
+}
+
+missing_in_basedir()
+{
+ echo "FATAL ERROR: Could not find $* inside --basedir"
+ echo
+ echo "When using --basedir you must point either into a MySQL binary"
+ echo "distribution directory or a compiled tree previously populated"
+ echo "by 'make install'"
+}
+
+# Ok, let's go. We first need to parse arguments which are required by
+# my_print_defaults so that we can execute it first, then later re-parse
+# the command line to add any extra bits that we need.
parse_arguments PICK-ARGS-FROM-ARGV "$@"
-test -z "$ldata" && ldata=@localstatedir@
-if test -z "$basedir"
+# We can now find my_print_defaults, either in the supplied --basedir
+# location or in the installed area.
+if test -n "$basedir"
then
- basedir=@prefix@
- bindir=@bindir@
- execdir=@libexecdir@
- pkgdatadir=@pkgdatadir@
-else
- bindir="$basedir/bin"
- if test -x "$basedir/libexec/mysqld"
+ print_defaults=`find_in_basedir my_print_defaults bin extra`
+ if ! test -x "$print_defaults"
then
- execdir="$basedir/libexec"
- elif test -x "$basedir/sbin/mysqld"
+ missing_in_basedir my_print_defaults
+ exit 1
+ fi
+else
+ print_defaults="@bindir@/my_print_defaults"
+ if ! test -x "$print_defaults"
then
- execdir="$basedir/sbin"
- else
- execdir="$basedir/bin"
+ echo "FATAL ERROR: Could not find $print_defaults"
+ echo
+ echo "If you are using a binary release, you must run this script from"
+ echo "within the directory the archive extracted into. If you compiled"
+ echo "MySQL yourself you must run 'make install' first."
+ exit 1
fi
fi
-# Find SQL scripts needed for bootstrap
-fill_help_tables="fill_help_tables.sql"
-create_system_tables="mysql_system_tables.sql"
-fill_system_tables="mysql_system_tables_data.sql"
-if test -n "$srcdir"
+# 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.
+parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
+parse_arguments PICK-ARGS-FROM-ARGV "$@"
+
+# Path to MySQL installation directory
+if test -z "$basedir"
then
- fill_help_tables=$srcdir/scripts/$fill_help_tables
- create_system_tables=$srcdir/scripts/$create_system_tables
- fill_system_tables=$srcdir/scripts/$fill_system_tables
+ basedir="@prefix@"
+ bindir="@bindir@"
+ mysqld="@libexecdir@/mysqld"
+ pkgdatadir="@pkgdatadir@"
else
- for i in $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/$fill_help_tables
+ bindir="$basedir/bin"
+ # We set up bootstrap-specific paths later, so skip this for --windows
+ if test "$windows" -eq 0
+ then
+ pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql`
+ if test -z "$pkgdatadir"
then
- pkgdatadir=$i
- break
+ missing_in_basedir fill_help_tables.sql
+ exit 1
fi
- done
-
- fill_help_tables=$pkgdatadir/$fill_help_tables
- create_system_tables=$pkgdatadir/$create_system_tables
- fill_system_tables=$pkgdatadir/$fill_system_tables
+ mysqld=`find_in_basedir mysqld libexec sbin bin`
+ if ! test -x "$mysqld"
+ then
+ missing_in_basedir mysqld
+ exit 1
+ fi
+ fi
fi
-if test ! -f $create_system_tables
+# Path to data directory
+if test -z "$ldata"
then
- echo "FATAL ERROR: Could not find SQL file '$create_system_tables' in"
- echo "@pkgdatadir@ or inside $basedir"
- exit 1;
+ ldata="@localstatedir@"
fi
-if test ! -f $fill_help_tables
+# Set up paths to SQL scripts required for bootstrap and ensure they exist.
+if test -n "$srcdir"
then
- echo "FATAL ERROR: Could not find help file '$fill_help_tables' in"
- echo "@pkgdatadir@ or inside $basedir"
- exit 1;
+ pkgdatadir="$srcdir/scripts"
fi
-if test ! -f $fill_system_tables
-then
- echo "FATAL ERROR: Could not find help file '$fill_system_tables' in"
- echo "@pkgdatadir@ or inside $basedir"
- exit 1;
-fi
+fill_help_tables="$pkgdatadir/fill_help_tables.sql"
+create_system_tables="$pkgdatadir/mysql_system_tables.sql"
+fill_system_tables="$pkgdatadir/mysql_system_tables_data.sql"
-# Find executables and paths
-mysqld=$execdir/mysqld
-mysqld_opt=""
-scriptdir=$bindir
+for f in $fill_help_tables $create_system_tables $fill_system_tables
+do
+ if test ! -f "$f"
+ then
+ echo "FATAL ERROR: Could not find SQL file '$f'"
+ exit 1
+ fi
+done
-if test "$windows" = 1
+# Set up Windows-specific paths
+if test "$windows" -eq 1
then
mysqld="./sql/mysqld"
- if test -n "$srcdir" -a -f $srcdir/sql/share/english/errmsg.sys
+ if test -n "$srcdir" -a -f "$srcdir/sql/share/english/errmsg.sys"
then
- langdir=$srcdir/sql/share/english
+ mysqld_opt="--language=$srcdir/sql/share/english"
else
- langdir=./sql/share/english
+ mysqld_opt="--language=./sql/share/english"
fi
- mysqld_opt="--language=$langdir"
- scriptdir="./scripts"
fi
-if test ! -x $mysqld
+# Make sure mysqld is available in default location (--basedir option is
+# already tested above).
+if test ! -x "$mysqld"
then
- if test "$in_rpm" = 1
- then
- echo "FATAL ERROR $mysqld not found!"
- exit 1
- else
- echo "FATAL ERROR Didn't find $mysqld"
- echo "You should do a 'make install' before executing this script"
- exit 1
- fi
+ echo "FATAL ERROR: $mysqld not found!"
+ exit 1
fi
# Try to determine the hostname
hostname=`@HOSTNAME@`
# Check if hostname is valid
-if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
+if test "$windows" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
then
resolved=`$bindir/resolveip $hostname 2>&1`
if [ $? -ne 0 ]
@@ -244,39 +305,35 @@ then
fi
fi
-if test "$ip_only" = "1"
+if test "$ip_only" -eq 1
then
- ip=`echo "$resolved" | awk '/ /{print $6}'`
- hostname=$ip
+ hostname=`echo "$resolved" | awk '/ /{print $6}'`
fi
# Create database directories mysql & test
-if test ! -d $ldata; then
- mkdir $ldata;
- chmod 700 $ldata ;
-fi
-if test ! -d $ldata/mysql; then
- mkdir $ldata/mysql;
- chmod 700 $ldata/mysql ;
-fi
-if test ! -d $ldata/test; then
- mkdir $ldata/test;
- chmod 700 $ldata/test ;
-fi
-if test -w / -a ! -z "$user"; then
- chown $user $ldata $ldata/mysql $ldata/test;
-fi
+for dir in $ldata $ldata/mysql $ldata/test
+do
+ if test ! -d $dir
+ then
+ mkdir -p $dir
+ chmod 700 $dir
+ fi
+ if test -w / -a ! -z "$user"
+ then
+ chown $user $dir
+ fi
+done
-if test -n "$user"; then
+if test -n "$user"
+then
args="$args --user=$user"
fi
# Peform the install of system tables
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
---basedir=$basedir --datadir=$ldata --skip-innodb \
---skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M \
---net_buffer_length=16K"
+ --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb \
+ --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
# Pipe mysql_system_tables.sql to "mysqld --bootstrap"
s_echo "Installing MySQL system tables..."
@@ -284,23 +341,20 @@ if `(echo "use mysql;"; cat $create_system_tables $fill_system_tables) | $mysqld
then
s_echo "OK"
- if test -n "$fill_help_tables"
+ 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`
then
- 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`
- then
- # Fill suceeded
- s_echo "OK"
- else
- echo ""
- echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!"
- echo "The \"HELP\" command might not work properly"
- echo ""
- fi
+ # Fill suceeded
+ s_echo "OK"
+ else
+ echo
+ echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!"
+ echo "The \"HELP\" command might not work properly"
+ echo
fi
- s_echo ""
+ s_echo
s_echo "To start mysqld at boot time you have to copy"
s_echo "support-files/mysql.server to the right place for your system"
s_echo
@@ -319,7 +373,7 @@ then
echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
echo "See the manual for more instructions."
- if test "$in_rpm" = "0"
+ if test "$in_rpm" -eq 0
then
echo "You can start the MySQL daemon with:"
echo "cd @prefix@ ; $bindir/mysqld_safe &"
diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh
index 9699cd28047..1f5509f9955 100644
--- a/scripts/mysql_setpermission.sh
+++ b/scripts/mysql_setpermission.sh
@@ -19,13 +19,14 @@
## 1.3 Applied patch provided by Martin Mokrejs <mmokrejs@natur.cuni.cz>
## (General code cleanup, use the GRANT statement instead of updating
## the privilege tables directly, added option to revoke privileges)
+## 1.4 Remove option 6 which attempted to erroneously grant global privileges
#### TODO
#
# empty ... suggestions ... mail them to me ...
-$version="1.3";
+$version="1.4";
use DBI;
use Getopt::Long;
@@ -103,13 +104,9 @@ sub q1 { # first question ...
print " existing database and host combination (user can do\n";
print " SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,\n";
print " LOCK TABLES,CREATE TEMPORARY TABLES)\n";
- print " 6. Create/append database administrative privileges for an\n";
- print " existing database and host combination (user can do\n";
- print " SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,\n";
- print " CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS)\n";
- print " 7. Create/append full privileges for an existing database\n";
+ print " 6. Create/append full privileges for an existing database\n";
print " and host combination (user has FULL privilege)\n";
- print " 8. Remove all privileges for for an existing database and\n";
+ print " 7. Remove all privileges for for an existing database and\n";
print " host combination.\n";
print " (user will have all permission fields set to N)\n";
print " 0. exit this program\n";
@@ -117,10 +114,10 @@ sub q1 { # first question ...
while (<STDIN>) {
$answer = $_;
chomp($answer);
- if ($answer =~ /^[12345678]$/) {
+ if ($answer =~ /^[1234567]$/) {
if ($answer == 1) {
setpwd();
- } elsif ($answer =~ /^[2345678]$/) {
+ } elsif ($answer =~ /^[234567]$/) {
addall($answer);
} else {
print "Sorry, something went wrong. With such option number you should not get here.\n\n";
@@ -233,7 +230,7 @@ sub addall {
}
}
- if ( ( !$todo ) or not ( $todo =~ m/^[2-8]$/ ) ) {
+ if ( ( !$todo ) or not ( $todo =~ m/^[2-7]$/ ) ) {
print STDERR "Sorry, select option $todo isn't known inside the program .. See ya\n";
quit();
}
@@ -256,12 +253,9 @@ sub addall {
# user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES
$sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
} elsif ($todo == 6) {
- # admin privileges: GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS
- $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
- } elsif ($todo == 7) {
# all privileges
$sth = $dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
- } elsif ($todo == 8) {
+ } elsif ($todo == 7) {
# all privileges set to N
$sth = $dbh->do("REVOKE ALL ON *.* FROM \'$user\'\@\'$host\'") || die $dbh->errstr;
}
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
index 61cd59457d1..6ad5c77b954 100644
--- a/scripts/mysqlhotcopy.sh
+++ b/scripts/mysqlhotcopy.sh
@@ -821,30 +821,14 @@ sub get_raid_dirs {
sub get_list_of_tables {
my ( $db ) = @_;
- # "use database" cannot cope with database names containing spaces
- # so create a new connection
-
- my $dbh = DBI->connect("dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy",
- $opt{user}, $opt{password},
- {
- RaiseError => 1,
- PrintError => 0,
- AutoCommit => 1,
- });
-
- my @dbh_tables = eval { $dbh->tables() };
-
- ## Remove quotes around table names
- my $quote = $dbh->get_info(29); # SQL_IDENTIFIER_QUOTE_CHAR
- if ($quote) {
- foreach (@dbh_tables) {
- s/^$quote(.*)$quote$/$1/;
- s/$quote$quote/$quote/g;
- }
- }
-
- $dbh->disconnect();
- return @dbh_tables;
+ my $tables =
+ eval {
+ $dbh->selectall_arrayref('SHOW TABLES FROM ' .
+ $dbh->quote_identifier($db))
+ } || [];
+ warn "Unable to retrieve list of tables in $db: $@" if $@;
+
+ return (map { $_->[0] } @$tables);
}
sub quote_names {