forked from evolix/ansible-roles
mysql: fix my-add.sh when no password
This commit is contained in:
parent
cfe7214bd0
commit
095693582a
|
@ -125,8 +125,9 @@ mysql_add() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ -z "${password}" ]; then
|
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 ..."
|
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=$?
|
grant=$?
|
||||||
else
|
else
|
||||||
echo -n "Grant '${user}' to '${db}' database with password '${password}' ..."
|
echo -n "Grant '${user}' to '${db}' database with password '${password}' ..."
|
||||||
|
|
Loading…
Reference in a new issue