eole-mariadb/scripts/mariadbPwd

20 lines
358 B
Bash

#!/bin/bash
#
# Renew MariaDB root password
# Just like old (mysql_pwd.py)
#
cmd="mysql"
options='--defaults-file=/etc/mysql/debian.cnf'
if [[ -z ${1} ]]
then
read -s -p "New Password : " password
echo
else
password="${1}"
fi
sql="FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY '${password}';"
${cmd} ${options} -e "${sql}"
exit $?