From c2b1de2394afaaa05db410d83698e3821186c87b Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Thu, 17 Oct 2024 12:21:37 +0100 Subject: [PATCH 1/3] Refactor MariaDB root password setting It looks like newer versions of Mariadb need a different method for doing this, also we weren't shutting it down and running in the right mode to set the new password --- provision/core/mariadb/provision.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/provision/core/mariadb/provision.sh b/provision/core/mariadb/provision.sh index bb6a83ef1..41c639627 100644 --- a/provision/core/mariadb/provision.sh +++ b/provision/core/mariadb/provision.sh @@ -87,17 +87,22 @@ SQL fi # Do reset password in safemode vvv_warn " * The root password is not root, fixing" + systemctl stop mariadb + mysqld_safe --skip-grant-tables --skip-networking & sql=$( cat <<-SQL - ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password USING PASSWORD('root'); + ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'; FLUSH PRIVILEGES; SQL ) - mysql -u root -proot -e "${sql}" + mysql -u root -e "${sql}" if [[ $? -eq 0 ]]; then vvv_success " - root user password should now be root" else vvv_warn " - could not reset root password" fi + sudo kill '/var/run/mariadb/mariadb.pid' + vvv_info " - restarting mariadb" + sudo systemctl start mariadb } function mysql_setup() { From b6297c5d1ddf95ac7ffb1497f1bfe96449849799 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Mon, 28 Oct 2024 17:46:59 +0000 Subject: [PATCH 2/3] Update provision.sh --- provision/core/mariadb/provision.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/provision/core/mariadb/provision.sh b/provision/core/mariadb/provision.sh index 41c639627..faeaab699 100644 --- a/provision/core/mariadb/provision.sh +++ b/provision/core/mariadb/provision.sh @@ -89,6 +89,8 @@ SQL vvv_warn " * The root password is not root, fixing" systemctl stop mariadb mysqld_safe --skip-grant-tables --skip-networking & + # give the safemode server a chance to start, + sleep 1 sql=$( cat <<-SQL ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'; FLUSH PRIVILEGES; From 0f6b77d4c3f02e1274fb06347f01defc05662b95 Mon Sep 17 00:00:00 2001 From: Tom J Nowell Date: Mon, 28 Oct 2024 18:07:04 +0000 Subject: [PATCH 3/3] flush mariadb privs to load grants before modifying them --- provision/core/mariadb/provision.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/provision/core/mariadb/provision.sh b/provision/core/mariadb/provision.sh index faeaab699..74301b43a 100644 --- a/provision/core/mariadb/provision.sh +++ b/provision/core/mariadb/provision.sh @@ -92,8 +92,9 @@ SQL # give the safemode server a chance to start, sleep 1 sql=$( cat <<-SQL - ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'; - FLUSH PRIVILEGES; + FLUSH PRIVILEGES; + ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'; + FLUSH PRIVILEGES; SQL ) mysql -u root -e "${sql}"