# Buggy code
async def _process_auth(self, plugin_name, auth_packet):
    if plugin_name == b"mysql_native_password":
        # https://dev.mysql.com/doc/internals/en/
        # secure-password-authentication.html#packet-Authentication::
        # Native41
        data = _auth.scramble_native_password(
            self._password.encode("latin1"), auth_packet.read_all()
        )
    elif plugin_name == b"mysql_old_password":
        # https://dev.mysql.com/doc/internals/en/
        # old-password-authentication.html
        data = (
            _auth.scramble_old_password(
                self._password.encode("latin1"), auth_packet.read_all()
            )
            + b"\0"
        )
    elif plugin_name == b"mysql_clear_password":
        # https://dev.mysql.com/doc/internals/en/
        # clear-text-authentication.html
        data = self._password.encode("latin1") + b"\0"
    else:
        raise OperationalError(
            2059, "Authentication plugin '%s' not configured" % plugin_name
        )

    self.write_packet(data)
    pkt = await self._read_packet()
    pkt.check_error()

    self._auth_plugin_used = plugin_name

    return pkt


# Traceback (pymysql.err.OperationalError)
mysql5 works

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/aiomysql/connection.py", line 464, in _connect
await self._request_authentication()
File "/usr/local/lib/python3.6/site-packages/aiomysql/connection.py", line 719, in _request_authentication
auth_packet = await self._read_packet()
File "/usr/local/lib/python3.6/site-packages/aiomysql/connection.py", line 554, in _read_packet
packet.check_error()
File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 384, in check_error
err.raise_mysql_exception(self._data)
File "/usr/local/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'test'@'172.18.0.3' (using password: NO)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "main.py", line 20, in <module>
asyncio.get_event_loop().run_until_complete(connect())
File "/usr/local/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
return future.result()
File "main.py", line 17, in connect
await aiomysql.connect(host='mysql8', **args)
File "/usr/local/lib/python3.6/site-packages/aiomysql/connection.py", line 76, in _connect
await conn._connect()
File "/usr/local/lib/python3.6/site-packages/aiomysql/connection.py", line 484, in _connect
self._host) from e
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'mysql8'")

# Fixed code
async def _process_auth(self, plugin_name, auth_packet):
    # These auth plugins do their own packet handling
    if plugin_name == b"caching_sha2_password":
        await self.caching_sha2_password_auth(auth_packet)
        self._auth_plugin_used = plugin_name.decode()
    elif plugin_name == b"sha256_password":
        await self.sha256_password_auth(auth_packet)
        self._auth_plugin_used = plugin_name.decode()
    else:
        if plugin_name == b"mysql_native_password":
            # https://dev.mysql.com/doc/internals/en/
            # secure-password-authentication.html#packet-Authentication::
            # Native41
            data = _auth.scramble_native_password(
                self._password.encode("latin1"), auth_packet.read_all()
            )
        elif plugin_name == b"mysql_old_password":
            # https://dev.mysql.com/doc/internals/en/
            # old-password-authentication.html
            data = (
                _auth.scramble_old_password(
                    self._password.encode("latin1"), auth_packet.read_all()
                )
                + b"\0"
            )
        elif plugin_name == b"mysql_clear_password":
            # https://dev.mysql.com/doc/internals/en/
            # clear-text-authentication.html
            data = self._password.encode("latin1") + b"\0"
        else:
            raise OperationalError(
                2059, "Authentication plugin '{0}' not configured".format(plugin_name)
            )

        self.write_packet(data)
        pkt = await self._read_packet()
        pkt.check_error()

        self._auth_plugin_used = plugin_name.decode()

        return pkt