Skip to content

MySQL Client Error: Authentication plugin not supported: caching_sha2_password #2

@hc2088

Description

@hc2088

MySQL Client Error: Authentication plugin not supported: caching_sha2_password

simple_mysql_orm:
dependency: "direct main"
description:
name: simple_mysql_orm
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.2"

```

Future<ConnectionWrapper> _validConnection(
ConnectionWrapper? conn) async {
var _conn = conn;
var retries = 30;
var success = false;

String? lastError;
while (!success && retries > 0) {
  try {
    if (_conn != null && await _conn.wrapped.test()) {
      success = true;
      break;
    } else {
      if (_conn != null) {
        _removeBadConnection(_conn);
        _conn = null;
      }
      retries--;
      _conn = await _createNew();
      success = true;
      break;
    }
    // ignore: avoid_catches_without_on_clauses
  } catch (e) {
    // remove the bad connection
    _removeBadConnection(_conn);
    _conn = null;
    lastError = e.toString();
    if (e is MySqlException) {
      /// no point retrying if its access denied.
      if (e.message.contains('Access denied for user')) {
        break;
      } else {
        await _logAndWait(lastError);
      }
    }
    if (e is StateError || e is MySqlException || e is SocketException) {
      await _logAndWait(lastError);
    } else {
      rethrow; //////
    }
  }
}
if (!success) {
  logger.severe('Unable to connect to db. $lastError');
  throw MySqlORMException('Unable to connect to db. $lastError');
}

return _conn!;


Rethrow; ////// An exception is thrown when this line of code is executed


MySQL Client Error: Authentication plugin not supported: caching_sha2_password

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions