Explorar o código

- make drop user work with older mysql releases

Jan Janak %!s(int64=19) %!d(string=hai) anos
pai
achega
0899f4803b
Modificáronse 1 ficheiros con 12 adicións e 5 borrados
  1. 12 5
      scripts/mysql/ser_mysql.sh

+ 12 - 5
scripts/mysql/ser_mysql.sh

@@ -215,11 +215,18 @@ drop_db()
     sql_query "" "REVOKE ALL PRIVILEGES ON ${DBNAME}.* FROM '${ROUSER}'@'%'"
     sql_query "" "REVOKE ALL PRIVILEGES ON ${DBNAME}.* FROM '${ROUSER}'@'localhost'"
 
-    if [ ! $KEEP_USERS ] ; then
-	sql_query "" "DROP USER '${RWUSER}'@'%'"
-	sql_query "" "DROP USER '${RWUSER}'@'localhost'"
-	sql_query "" "DROP USER '${ROUSER}'@'%'"
-	sql_query "" "DROP USER '${ROUSER}'@'localhost'"
+    if [ ! -z "$KEEP_USERS" ] ; then
+	    # Works only with MySQL 4.1.1 and higher
+		#sql_query "" "DROP USER '${RWUSER}'@'%'"
+		#sql_query "" "DROP USER '${RWUSER}'@'localhost'"
+		#sql_query "" "DROP USER '${ROUSER}'@'%'"
+		#sql_query "" "DROP USER '${ROUSER}'@'localhost'"
+		
+		# Works with older MySQL versions
+		sql_query "" "DELETE FROM mysql.user WHERE User='${RWUSER}' and Host='%'"
+		sql_query "" "DELETE FROM mysql.user WHERE User='${RWUSER}' and Host='localhost'"
+		sql_query "" "DELETE FROM mysql.user WHERE User='${ROUSER}' and Host='%'"
+		sql_query "" "DELETE FROM mysql.user WHERE User='${ROUSER}' and Host='localhost'"
     fi
 
     sql_query "" "FLUSH PRIVILEGES"