fix Bug 62854 - Add the use of the default authentication plugin for mysql (#1489)

* Change default mysql authentication plugin to caching_sha2_password

* Add the use of default authentication plugin for mysql
This commit is contained in:
Evgeniy Antonyuk 2023-06-26 14:10:07 +05:00 committed by GitHub
parent e2a5c97087
commit cc2f8bde48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View File

@ -65,8 +65,11 @@ if [ "${MYSQL_FIRST_TIME_INSTALL}" = "true" ]; then
MYSQL_ROOT_PASS=$(echo $MYSQL_TEMPORARY_ROOT_PASS | sed -e 's/;/%/g' -e 's/=/%/g');
fi
$MYSQL -e "ALTER USER '${MYSQL_SERVER_USER}'@'localhost' IDENTIFIED WITH mysql_native_password BY '${MYSQL_ROOT_PASS}'" >/dev/null 2>&1 \
|| $MYSQL -e "UPDATE user SET plugin='mysql_native_password', authentication_string=PASSWORD('${MYSQL_ROOT_PASS}') WHERE user='${MYSQL_SERVER_USER}' and host='localhost';"
MYSQL_AUTHENTICATION_PLUGIN=$($MYSQL -e "SHOW VARIABLES LIKE 'default_authentication_plugin';" -s | awk '{print $2}')
MYSQL_AUTHENTICATION_PLUGIN=${MYSQL_AUTHENTICATION_PLUGIN:-caching_sha2_password}
$MYSQL -e "ALTER USER '${MYSQL_SERVER_USER}'@'localhost' IDENTIFIED WITH ${MYSQL_AUTHENTICATION_PLUGIN} BY '${MYSQL_ROOT_PASS}'" >/dev/null 2>&1 \
|| $MYSQL -e "UPDATE user SET plugin='${MYSQL_AUTHENTICATION_PLUGIN}', authentication_string=PASSWORD('${MYSQL_ROOT_PASS}') WHERE user='${MYSQL_SERVER_USER}' and host='localhost';"
systemctl restart mysqld
fi

View File

@ -397,10 +397,13 @@ change_mysql_config(){
sed "s/collation_server.*/collation_server = utf8_general_ci/" -i ${CNF_PATH} || true # ignore errors
fi
MYSQL_AUTHENTICATION_PLUGIN=$($MYSQL -e "SHOW VARIABLES LIKE 'default_authentication_plugin';" -s | awk '{print $2}')
MYSQL_AUTHENTICATION_PLUGIN=${MYSQL_AUTHENTICATION_PLUGIN:-caching_sha2_password}
if ! grep -q "^default-authentication-plugin" ${CNF_PATH}; then
sed '/\[mysqld\]/a default-authentication-plugin = mysql_native_password' -i ${CNF_PATH}
sed "/\[mysqld\]/a default-authentication-plugin = ${MYSQL_AUTHENTICATION_PLUGIN}" -i ${CNF_PATH}
else
sed "s/default-authentication-plugin.*/default-authentication-plugin = mysql_native_password/" -i ${CNF_PATH} || true # ignore errors
sed "s/default-authentication-plugin.*/default-authentication-plugin = ${MYSQL_AUTHENTICATION_PLUGIN}/" -i ${CNF_PATH} || true # ignore errors
fi
if [ -e ${CNF_SERVICE_PATH} ]; then

View File

@ -3,7 +3,7 @@ version: "3.8"
services:
onlyoffice-mysql-server:
image: ${MYSQL_IMAGE}
command: --default-authentication-plugin=mysql_native_password
command: --default-authentication-plugin=caching_sha2_password
cap_add:
- SYS_NICE
container_name: ${MYSQL_HOST}

View File

@ -180,7 +180,7 @@ Function MySQLConfigure
If service.Started Then
shell.Run """" & installDir & "bin\mysqladmin"" -u root password " & dbpass, 0, true
shell.Run """" & installDir & "bin\mysql"" -u root -p" & dbpass & " -e ""ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY " & "'" & dbpass & "';""", 0, true
shell.Run """" & installDir & "bin\mysql"" -u root -p" & dbpass & " -e ""ALTER USER 'root'@'localhost' IDENTIFIED BY " & "'" & dbpass & "';""", 0, true
End If
Set filesys = CreateObject("Scripting.FileSystemObject")
@ -191,7 +191,6 @@ Function MySQLConfigure
WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "group_concat_max_len", "2048"
WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "character_set_server", "utf8"
WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "collation_server", "utf8_general_ci"
WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "default-authentication-plugin", "mysql_native_password"
Call WriteToLog("MySQLConfigure: WriteIni Path" & filesys.BuildPath(dataDir, "my.ini"))