MySQL 8.4.0
Source Code Documentation

Changes the user of the current connection.

Also and resets the following connection state:

  • user variables
  • temporary tables
  • prepared statements
  • ... and others

It is going through the same states as the Initial Handshake

Protocol::AuthSwitchRequest: or ERR_Packet
int<1> command 0x11: COM_CHANGE_USER
string<NUL> user user name
if capabilities & CLIENT_SECURE_CONNECTION {
int<1> auth_plugin_data_len length of auth_response
$length auth_plugin_data authentication data
} else {
string<NUL> auth_plugin_data authentication data (9 bytes)
string<NUL> database schema name
if more data available {
if capabilities & CLIENT_PROTOCOL_41 {
int<2> character_set new connection character set. See Character Set
if capabilities & CLIENT_PLUGIN_AUTH {
string<NUL> auth_plugin_name client authentication plugin name used to generate auth_plugin_data
if capabilities & CLIENT_CONNECT_ATTRS {
int<lenenc> connection_attributes_length length in bytes of the following block of key-value pairs
$length key Key name
$length value value of key
more key/value pairs until connection_attributes_length is depleted
} – more data available

Please also read Authentication After COM_CHANGE_USER Command

See also
mysql_change_user, send_change_user_packet, parse_com_change_user_packet, acl_authenticate, dispatch_command