eole-mariadb/scripts/mariadbPwd
Philippe Caseiro 1dc370fb94 Clean root password Management
Don't store the root password.
Provide easy replacement for mysql_pwd.py
2018-04-12 16:01:43 +02:00

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 $?