MySQL 5.7 is old, and the latest versions fail on "GRANT USAGE" if the
user does not exist. "DROP USER IF EXISTS" has been with us since 5.7,
so all users should have it by now. This patch fixes the issue.
To test:
Try to koha_remove a site, and if it works with no errors, all good!
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
then
# The grant creates the user in case it isn't, we don't want our loop to fail if it has already being deleted.
mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
-GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`%\`;
-GRANT USAGE ON \`koha_$name\`.* TO \`koha_$name\`@\`$mysql_hostname\`;
-DROP USER \`koha_$name\`@\`%\`;
-DROP USER \`koha_$name\`@\`$mysql_hostname\`;
+DROP USER IF EXISTS \`koha_$name\`@\`%\`;
+DROP USER IF EXISTS \`koha_$name\`@\`$mysql_hostname\`;
DROP DATABASE IF EXISTS \`koha_$name\`;
FLUSH PRIVILEGES;
eof