instead of assuming that SHOW TABLES; gives us GRANT privileges, simply try to GRANT with our multiple techniques

Fixes: #1060
This commit is contained in:
Antoine Beaupré 2007-08-27 16:33:31 +00:00
parent b2afdbbf4d
commit 556cf1c5bb
1 changed files with 11 additions and 17 deletions

View File

@ -42,17 +42,6 @@ fi
mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf -h$sqlserver " mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf -h$sqlserver "
if ! $mysql mysql -e "SHOW TABLES" >/dev/null
then
# is this an upgrade then?
mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass"
if ! $mysql mysql -e "SHOW TABLES" >/dev/null
then
echo "Can't get proper credentials, aborting"
exit 1
fi
fi
# The grant all is the most important right needed in this script. # The grant all is the most important right needed in this script.
# If this call fail, we may be connected to a mysql-server version 5.0. # If this call fail, we may be connected to a mysql-server version 5.0.
echo "Granting users " echo "Granting users "
@ -60,9 +49,13 @@ echo "Granting users "
$mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION"
if [ "$?" -ne "0" ] if [ "$?" -ne "0" ]
then then
echo "You are using mysql 5.0, so we try with root account and no password since debian-sys-maint doesn't work." echo "debian-sys-maintainer doesn't have the right credentials, assuming we're doing an upgrade"
mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass"
$mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION"
if [ "$?" -ne "0" ]
then
echo "Still not working, assuming clean install and empty root password"
mysql="/usr/bin/mysql -h$sqlserver -uroot " mysql="/usr/bin/mysql -h$sqlserver -uroot "
echo "Granting users "
$mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION"
if [ "$?" -ne "0" ] if [ "$?" -ne "0" ]
then then
@ -70,6 +63,7 @@ then
exit 1 exit 1
fi fi
fi fi
fi
# Now we can use rootlogin and rootpass. # Now we can use rootlogin and rootpass.
mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass" mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass"