Skip to content

Commit 3f55955

Browse files
authored
Update mysql.sh
.
1 parent 94c426b commit 3f55955

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

database_server/mysql.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ database_user_password=`date | md5sum | fold -w 12 | head -n 1`
1414
## Database user password will be stored in /var/log/check.log ##
1515
## Remove /var/log/check.log after retrieving password . ##
1616

17-
database_availability_check=`mysqlshow --user=root --password=$database_root_password | grep -ow $database_name`
17+
database_availability_check=none
1818

19-
if [ "$database_availability_check" == "$database_name" ]; then
20-
exit 1
21-
else
19+
while [ "$database_availability_check" != "$database_name" ]; do
20+
database_availability_check=`mysqlshow --user=root --password=$database_root_password | grep -ow $database_name`
21+
mysql -u root -p$database_root_password -e "grant all on *.* to 'root'@'%' identified by '$database_root_password';"
2222
mysql -u root -p$database_root_password -e "create database $database_name;"
2323
mysql -u root -p$database_root_password -e "grant all on $database_name.* to '$database_user'@'%' identified by '$database_user_password';"
2424
echo "Your database user "$database_user" password for database "$database_name" is "$database_user_password"" > /var/log/check.log
25-
fi
25+
done
26+
2627

0 commit comments

Comments
 (0)