mysql: fix my-add.sh when no password

This commit is contained in:
Victor LABORIE 2017-01-12 15:15:22 +01:00
parent cfe7214bd0
commit 095693582a

View file

@ -125,8 +125,9 @@ mysql_add() {
exit 1
fi
if [ -z "${password}" ]; then
password=$(mysql mysql -Ne "SELECT Password FROM user WHERE User='${user}' AND Host='localhost';")
echo -n "Grant '${user}' to '${db}' database ..."
mysql -e "GRANT ALL PRIVILEGES ON ${db}.* TO ${user}@localhost;"
mysql -e "GRANT ALL PRIVILEGES ON ${db}.* TO ${user}@localhost IDENTIFIED BY PASSWORD '${password}';"
grant=$?
else
echo -n "Grant '${user}' to '${db}' database with password '${password}' ..."