From 598331cff914a80206eda5dba4ff09f028966623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 17 Jan 2021 23:32:50 +0100 Subject: [PATCH] When calling mysql_change_user set collation to default for the given charset if collation ID is greater or equal than 255 (utf8mb4_0900_ai_ci) We call mysql_options with MYSQL_SET_CHARSET_NAME if collation ID >= 255 . This to solve the problem of MySQL server returning an Access denied if the backend doesn't support a collation during mysql_change_user --- lib/MySQL_HostGroups_Manager.cpp | 5 +++++ lib/mysql_connection.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 0aee6acba..e3540cb19 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -686,6 +686,11 @@ static void * HGCU_thread_run() { } } //async_exit_status = mysql_change_user_start(&ret_bool,mysql,_ui->username, auth_password, _ui->schemaname); + // we first reset the charset to a default one. + // this to solve the problem described here: + // https://github.com/sysown/proxysql/pull/3249#issuecomment-761887970 + if (myconn->mysql->charset->nr >= 255) + mysql_options(myconn->mysql, MYSQL_SET_CHARSET_NAME, myconn->mysql->charset->csname); statuses[i]=mysql_change_user_start(&ret[i], myconn->mysql, myconn->userinfo->username, auth_password, myconn->userinfo->schemaname); if (myconn->mysql->net.pvio==NULL || myconn->mysql->net.fd==0 || myconn->mysql->net.buff==NULL) { statuses[i]=0; ret[i]=1; diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 0a6b44f87..5ab2ca4f4 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -646,6 +646,11 @@ void MySQL_Connection::change_user_start() { auth_password=userinfo->password; } } + // we first reset the charset to a default one. + // this to solve the problem described here: + // https://github.com/sysown/proxysql/pull/3249#issuecomment-761887970 + if (mysql->charset->nr >= 255) + mysql_options(mysql, MYSQL_SET_CHARSET_NAME, mysql->charset->csname); async_exit_status = mysql_change_user_start(&ret_bool,mysql,_ui->username, auth_password, _ui->schemaname); }