create_database.sh: add support for MySQL version 8.0.x
This commit is contained in:
parent
bbed466b7f
commit
dafc793007
@ -390,6 +390,34 @@ if ! $QUIET_MODE ; then
|
|||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# - Get MySQL Version
|
||||||
|
# -
|
||||||
|
echononl " Get MySQL Version"
|
||||||
|
_version="$(mysql $MYSQL_CREDENTIAL_ARGS -N -s -e "SELECT VERSION()" 2> $tmp_log_file)"
|
||||||
|
if [[ $? -ne 0 ]] ; then
|
||||||
|
echo_failed
|
||||||
|
fatal "$(cat $tmp_log_file)"
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
|
||||||
|
IFS='.' read -r -a version_arr <<< "$_version"
|
||||||
|
declare -i MAJOR_VERSION="${version_arr[0]}"
|
||||||
|
declare -i MINOR_VERSION="${version_arr[1]}"
|
||||||
|
_path_level="${version_arr[2]}"
|
||||||
|
declare -i PATCH_LEVEL="${_path_level%%-*}"
|
||||||
|
|
||||||
|
if ! $QUIET_MODE ; then
|
||||||
|
if [[ $MAJOR_VERSION -gt 8 ]] \
|
||||||
|
|| ( [[ $MAJOR_VERSION -eq 8 ]] && [[ $MINOR_VERSION -gt 0 ]] ) \
|
||||||
|
|| ( [[ $MAJOR_VERSION -eq 8 ]] && [[ $MINOR_VERSION -eq 0 ]] && [[ $PATCH_LEVEL -ge 3 ]] ) ; then
|
||||||
|
|
||||||
|
info "Using (old) Password Plugin 'mysql_native_password'"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# - Test if Database already exists
|
# - Test if Database already exists
|
||||||
# -
|
# -
|
||||||
@ -408,15 +436,44 @@ else
|
|||||||
echo_ok
|
echo_ok
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echononl " Grant full access to user '$DATABASE_USER' on Database '$DATABASE_NAME'"
|
if [[ $MAJOR_VERSION -gt 8 ]] \
|
||||||
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
|| ( [[ $MAJOR_VERSION -eq 8 ]] && [[ $MINOR_VERSION -gt 0 ]] ) \
|
||||||
"GRANT ALL ON ${DATABASE_NAME}.* TO '$DATABASE_USER'@'localhost' IDENTIFIED BY '$DATABASE_PASSWD'" > $tmp_log_file 2>&1
|
|| ( [[ $MAJOR_VERSION -eq 8 ]] && [[ $MINOR_VERSION -eq 0 ]] && [[ $PATCH_LEVEL -ge 3 ]] ) ; then
|
||||||
if [[ $? -ne 0 ]] ; then
|
|
||||||
echo_failed
|
echononl " Create database user '$DATABASE_USER'"
|
||||||
error "$(cat $tmp_log_file)"
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
"CREATE USER '$DATABASE_USER'@'localhost' IDENTIFIED WITH mysql_native_password 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 full access to user '$DATABASE_USER' on Database '$DATABASE_NAME'"
|
||||||
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
"GRANT ALL 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
|
||||||
|
|
||||||
else
|
else
|
||||||
echo_ok
|
|
||||||
fi
|
echononl " Grant full access to user '$DATABASE_USER' on Database '$DATABASE_NAME'"
|
||||||
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
"GRANT ALL ON ${DATABASE_NAME}.* TO '$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
|
||||||
|
|
||||||
|
fi # if [[ $MAJOR_VERSION -ge 8 ]]
|
||||||
|
|
||||||
echononl " Also grant 'Super_priv' privilege to '$DATABASE_USER' on Database '$DATABASE_NAME'"
|
echononl " Also grant 'Super_priv' privilege to '$DATABASE_USER' on Database '$DATABASE_NAME'"
|
||||||
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
|
||||||
|
Loading…
Reference in New Issue
Block a user