diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0769e1eb395..08d747b9743 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -12828,15 +12828,6 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio) ACL_USER *user= find_user_or_anon(sctx->host, sctx->user, sctx->ip); - if (user && user->password_errors >= max_password_errors && !ignore_max_password_errors(user)) - { - mysql_mutex_unlock(&acl_cache->lock); - my_error(ER_USER_IS_BLOCKED, MYF(0)); - general_log_print(mpvio->auth_info.thd, COM_CONNECT, - ER_THD(mpvio->auth_info.thd, ER_USER_IS_BLOCKED)); - DBUG_RETURN(1); - } - if (user) mpvio->acl_user= user->copy(mpvio->auth_info.thd->mem_root); @@ -12873,6 +12864,15 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio) mpvio->make_it_fail= true; } + if (mpvio->acl_user->password_errors >= max_password_errors && + !ignore_max_password_errors(mpvio->acl_user)) + { + my_error(ER_USER_IS_BLOCKED, MYF(0)); + general_log_print(mpvio->auth_info.thd, COM_CONNECT, + ER_THD(mpvio->auth_info.thd, ER_USER_IS_BLOCKED)); + DBUG_RETURN(1); + } + /* user account requires non-default plugin and the client is too old */ if (mpvio->acl_user->auth->plugin.str != native_password_plugin_name.str && mpvio->acl_user->auth->plugin.str != old_password_plugin_name.str &&