Skip to content

Support MySQL 8.0 Connector/C for MySQL-DBI extension #2526

Description

@HotoCocoaco

Help us help you

Is your feature request related to a problem? Please describe.

The MySQL-DBI extension is currently compiled against MySQL 5.x client library, which only supports the mysql_native_password authentication plugin.

MySQL 8.0.4+ changed the default authentication plugin to caching_sha2_password. When a MySQL 8.0 server uses this default authentication, the MySQL-DBI extension fails to connect with:
Error: [1045]: proxy authentication failed: invalid password
This does not affect all MySQL 8.0 servers — if the server or database user is configured to use mysql_native_password (e.g., IDENTIFIED WITH mysql_native_password BY '...'), the current extension works fine. However, some users ( those who rent a shared database server, me) have no way to change the authentication method and are unable to connect.

Additionally, MySQL 5.x reached End of Life in 2023, and compiling against a modern client library is a natural step forward.
(mine is 8.0.40)

Describe the solution you'd like

I have prepared a patch that migrates the MySQL-DBI extension from MySQL 5.x client library to MySQL 8.0 Connector/C. The changes include:

  • Remove incompatible headers (my_global.h, my_sys.h) that were deleted in MySQL 8.0
  • Replace deprecated my_bool type with bool (removed in MySQL 8.0)
  • Guard MYSQL_OPT_RECONNECT with a version check (MYSQL_VERSION_ID < 80100) since it was deprecated in 8.0 and removed in 8.1
  • Update AMBuilder to detect and link against MySQL 8.0 library (libmysql.lib / libmysqlclient.so)
  • Update configure.py to accept MySQL 8.0 Connector/C paths
  • Update AMBuildScript to detect MYSQL80 / MYSQL80_64 environment variables

The patch is backwards compatible — the same code still compiles against MySQL 5.x headers without issues, and MySQL 8.0 client library supports connecting to both MySQL 5.x and 8.0 servers.

Describe alternatives you've considered

  • Using mysql-native-password authentication on MySQL 8.0+ servers (requires server-side changes and is less secure)
  • Downgrading to MySQL 5.7 (not feasible for many users who don't control their database server)
  • Using a wrapper driver (would introduce additional complexity and maintenance burden)

Additional context

The patch has been tested and confirmed working:

  • Compiled on Ubuntu 22.04 with libmysqlclient-dev (MySQL 8.0 Connector/C)
  • Links against libmysqlclient.so.21
  • Successfully connects to a remote MySQL 8.0.40 server from a SourceMod 1.12.0.7246 server
  • The resulting .so is 87KB (dynamic linking) vs the original 4MB (static linking), but this can be made static if desired

The branch is available at: https://github.com/HotoCocoaco/sourcemod/tree/dbi-mysql-8.0.40

I would wait for some feedback before making a pr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions