--- rpms/smeserver-mysql/sme10/smeserver-mysql-2.7.0-bz12145-backupuserprivileges.patch 2024/09/01 04:21:50 1.1 +++ rpms/smeserver-mysql/sme10/smeserver-mysql-2.7.0-bz12145-backupuserprivileges.patch 2024/09/05 14:04:25 1.2 @@ -39,14 +39,14 @@ diff -Nur --no-dereference smeserver-mys +# will also need to exclude mysql.user from restore in mariadb >= 103 +# inspired by https://stackoverflow.com/a/56588240 +# for mariadb 5.5 we replace authentication_string with Password -+mysql $@ -sNe " \ ++mysql -sNe " \ + SELECT \ + CONCAT( 'CREATE USER \'', User, '\'@\'', Host, '\' IDENTIFIED BY \'', Password, '\'\;' ) AS User \ + FROM mysql.user \ + WHERE \ + User NOT LIKE 'mysql.%' AND CONCAT( User, Host ) <> 'rootlocalhost' \ +" >/home/e-smith/db/mysql/mysql.privileges.dump -+mysql $@ -sNe " \ ++mysql -sNe " \ + SELECT \ + CONCAT( '\'', User, '\'@\'', Host, '\'' ) as User FROM mysql.user \ + WHERE \ @@ -54,7 +54,7 @@ diff -Nur --no-dereference smeserver-mys + AND CONCAT( User, Host ) <> 'rootlocalhost' \ +" | sort | while read u ; + do echo "-- $u">> /home/e-smith/db/mysql/mysql.privileges.dump -+ mysql $@ -sNe "show grants for $u" | sed 's/$/;/' >> /home/e-smith/db/mysql/mysql.privileges.dump ++ mysql -sNe "show grants for $u" | sed 's/$/;/' >> /home/e-smith/db/mysql/mysql.privileges.dump done +echo >> /home/e-smith/db/mysql/mysql.privileges.dump +echo "FLUSH PRIVILEGES;" >> /home/e-smith/db/mysql/mysql.privileges.dump @@ -98,14 +98,14 @@ diff -Nur --no-dereference smeserver-mys +# would allow compatible backup from mariadb <103 to mariadb >= 103 +# will also need to exclude mysql.user from restore in mariadb >= 103 +# inspired by https://stackoverflow.com/a/56588240 -+/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql $@ -sNe " \ ++/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql -sNe " \ + SELECT \ + CONCAT( 'CREATE USER \'', User, '\'@\'', Host, '\' IDENTIFIED BY \'', authentication_string, '\'\;' ) AS User \ + FROM mysql.user \ + WHERE \ + User NOT LIKE 'mysql.%' AND CONCAT( User, Host ) <> 'rootlocalhost' \ +" >/home/e-smith/db/mariadb!!!VER!!!/mysql.privileges.dump -+/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql $@ -sNe " \ ++/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql -sNe " \ + SELECT \ + CONCAT( '\'', User, '\'@\'', Host, '\'' ) as User FROM mysql.user \ + WHERE \ @@ -113,7 +113,7 @@ diff -Nur --no-dereference smeserver-mys + AND CONCAT( User, Host ) <> 'rootlocalhost' \ +" | sort | while read u ; + do echo "-- $u">> /home/e-smith/db/mariadb!!!VER!!!/mysql.privileges.dump -+ /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql $@ -sNe "show grants for $u" | sed 's/$/;/' >> /home/e-smith/db/mariadb!!!VER!!!/mysql.privileges.dump ++ /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql -sNe "show grants for $u" | sed 's/$/;/' >> /home/e-smith/db/mariadb!!!VER!!!/mysql.privileges.dump done +echo >> /home/e-smith/db/mariadb!!!VER!!!/mysql.privileges.dump +echo "FLUSH PRIVILEGES;" >> /home/e-smith/db/mariadb!!!VER!!!/mysql.privileges.dump