create_database.sh: support mariadb 10.4
This commit is contained in:
parent
b18c6a1a0e
commit
52b57aafea
@ -666,6 +666,60 @@ if [[ "$MYSQL_CUR_DISTRIBUTION" = "MySQL" ]] && ([[ $MAJOR_VERSION -gt 8 ]] \
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
elif [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] && ([[ $MAJOR_VERSION -gt 10 ]] \
|
||||||
|
|| ( [[ $MAJOR_VERSION -eq 10 ]] && [[ $MINOR_VERSION -gt 3 ]] )) ; then
|
||||||
|
|
||||||
|
echononl " Create database user '$DATABASE_USER'"
|
||||||
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
"CREATE USER '$DATABASE_USER'@'localhost' IDENTIFIED BY '$DATABASE_PASSWD'" \
|
||||||
|
> $tmp_log_file 2>&1
|
||||||
|
if [[ $? -ne 0 ]] ; then
|
||||||
|
echo_failed
|
||||||
|
error "$(cat $tmp_log_file)"
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
|
||||||
|
echononl " Grant permissions to access and use the MySQL server to user '$DATABASE_USER'"
|
||||||
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
"GRANT USAGE ON \`$DATABASE_NAME\`.* TO '$DATABASE_USER'@'localhost'" \
|
||||||
|
> $tmp_log_file 2>&1
|
||||||
|
if [[ $? -ne 0 ]] ; then
|
||||||
|
echo_failed
|
||||||
|
error "$(cat $tmp_log_file)"
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
|
||||||
|
echononl " Grant all privileges to a user '$DATABASE_USER' on database '$DATABASE_NAME'"
|
||||||
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
"GRANT ALL privileges ON \`$DATABASE_NAME\`.* TO '$DATABASE_USER'@'localhost'" \
|
||||||
|
> $tmp_log_file 2>&1
|
||||||
|
if [[ $? -ne 0 ]] ; then
|
||||||
|
echo_failed
|
||||||
|
error "$(cat $tmp_log_file)"
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $ACCESS_FROM_OUTSIDE ; then
|
||||||
|
|
||||||
|
for _ip in $IP_ADDRESSES ; do
|
||||||
|
|
||||||
|
echononl " Allow access to user '$DATABASE_USER' on Database '$DATABASE_NAME' from '$_ip'"
|
||||||
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
"GRANT USAGE ON `${DATABASE_NAME}`.* TO '$DATABASE_USER'@'$_ip'" > $tmp_log_file 2>&1
|
||||||
|
if [[ $? -ne 0 ]] ; then
|
||||||
|
echo_failed
|
||||||
|
error "$(cat $tmp_log_file)"
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
echononl " Grant usage to user '$DATABASE_USER' (Creates User..)"
|
echononl " Grant usage to user '$DATABASE_USER' (Creates User..)"
|
||||||
|
Loading…
Reference in New Issue
Block a user