Skip to content

Commit

Permalink
Fix deprecation warning from MariaDB 11 (#1904)
Browse files Browse the repository at this point in the history
* feat: update to use mariadb instead of mysql

* fix: mariadb upgrade
  • Loading branch information
ALameLlama authored Nov 1, 2023
1 parent d0b7849 commit 6c9656a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
24 changes: 8 additions & 16 deletions scripts/create-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 14 additions & 16 deletions scripts/features/mariadb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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

0 comments on commit 6c9656a

Please sign in to comment.