Skip to content

Commit

Permalink
Refactor MariaDB root password setting
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tomjn authored Oct 17, 2024
1 parent 2e2c436 commit c2b1de2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions provision/core/mariadb/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c2b1de2

Please sign in to comment.