From 6c9656ae9b30c1026e0d30f963f53fef6161cd24 Mon Sep 17 00:00:00 2001 From: Nicholas C <55490546+LlamaDuckGoose@users.noreply.github.com> Date: Thu, 2 Nov 2023 03:43:10 +1100 Subject: [PATCH] Fix deprecation warning from MariaDB 11 (#1904) * feat: update to use mariadb instead of mysql * fix: mariadb upgrade --- scripts/create-mysql.sh | 24 ++++++++---------------- scripts/features/mariadb.sh | 30 ++++++++++++++---------------- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/scripts/create-mysql.sh b/scripts/create-mysql.sh index 481d2f532..4bf5d402b 100755 --- a/scripts/create-mysql.sh +++ b/scripts/create-mysql.sh @@ -16,24 +16,16 @@ EOF chown vagrant /home/vagrant/.my.cnf +DB=$1 -DB=$1; - -mysql=$(ps ax | grep mysql | wc -l) mariadb=$(ps ax | grep mariadb | wc -l) +mysql=$(ps ax | grep mysql | wc -l) -if [ "$mysql" -gt 1 ] -then - mysql -e "CREATE DATABASE IF NOT EXISTS \`$DB\` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci"; -else - # Skip Creating MySQL database - echo "We didn't find MySQL (\$mysql), skipping \$DB creation" -fi - -if [ "$mariadb" -gt 1 ] -then - mysql -e "CREATE DATABASE IF NOT EXISTS \`$DB\` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci"; +if [ "$mariadb" -gt 1 ]; then + mariadb -e "CREATE DATABASE IF NOT EXISTS \`$DB\` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci" +elif [ "$mysql" -gt 1 ]; then + mysql -e "CREATE DATABASE IF NOT EXISTS \`$DB\` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci" else - # Skip Creating MariaDB database - echo "We didn't find MariaDB (\$mariadb), skipping \$DB creation" + # Skip Creating database + echo "We didn't find MariaDB (\$mariadb) or MySQL (\$mysql), skipping \`$DB\` creation" fi diff --git a/scripts/features/mariadb.sh b/scripts/features/mariadb.sh index fa3b679eb..989374ea7 100755 --- a/scripts/features/mariadb.sh +++ b/scripts/features/mariadb.sh @@ -10,8 +10,7 @@ fi export DEBIAN_FRONTEND=noninteractive -if [ -f /home/$WSL_USER_NAME/.homestead-features/mariadb ] -then +if [ -f /home/$WSL_USER_NAME/.homestead-features/mariadb ]; then echo "MariaDB already installed." exit 0 fi @@ -34,13 +33,12 @@ rm -rf /var/log/mysql rm -rf /etc/mysql # Determine version from config - set -- "$1" -IFS="."; +IFS="." # Add Maria PPA if [ -z "${version}" ]; then - curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash + curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash else curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash sudo bash mariadb_repo_setup --mariadb-server-version="$version" @@ -50,7 +48,7 @@ fi debconf-set-selections <<< "mariadb-server mysql-server/data-dir select ''" debconf-set-selections <<< "mariadb-server mysql-server/root_password password secret" debconf-set-selections <<< "mariadb-server mysql-server/root_password_again password secret" -mkdir /etc/mysql +mkdir /etc/mysql touch /etc/mysql/debian.cnf # Install MariaDB @@ -68,17 +66,17 @@ EOF export MYSQL_PWD=secret -mysql --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO root@'localhost' IDENTIFIED BY 'secret' WITH GRANT OPTION;" -mysql --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO root@'0.0.0.0' IDENTIFIED BY 'secret' WITH GRANT OPTION;" -service mysql restart +mariadb --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO root@'localhost' IDENTIFIED BY 'secret' WITH GRANT OPTION;" +mariadb --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO root@'0.0.0.0' IDENTIFIED BY 'secret' WITH GRANT OPTION;" +service mariadb restart -mysql --user="root" --password="secret" -h localhost -e "CREATE USER IF NOT EXISTS 'homestead'@'0.0.0.0' IDENTIFIED BY 'secret';" -mysql --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO 'homestead'@'0.0.0.0' IDENTIFIED BY 'secret' WITH GRANT OPTION;" -mysql --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO 'homestead'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION;" -mysql --user="root" --password="secret" -h localhost -e "FLUSH PRIVILEGES;" -service mysql restart +mariadb --user="root" --password="secret" -h localhost -e "CREATE USER IF NOT EXISTS 'homestead'@'0.0.0.0' IDENTIFIED BY 'secret';" +mariadb --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO 'homestead'@'0.0.0.0' IDENTIFIED BY 'secret' WITH GRANT OPTION;" +mariadb --user="root" --password="secret" -h localhost -e "GRANT ALL ON *.* TO 'homestead'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION;" +mariadb --user="root" --password="secret" -h localhost -e "FLUSH PRIVILEGES;" +service mariadb restart -mysql_upgrade --user="root" --verbose --force -service mysql restart +mariadb-upgrade --user="root" --verbose --force +service mariadb restart unset MYSQL_PWD