Skip to content

fix(admin): make Create User work on MariaDB - #564

Merged
EVWorth merged 1 commit into
mainfrom
fix/admin-mariadb-create-user
Sep 8, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/admin-mariadb-create-user

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Closes #561.

The bug

The dialog emitted the same statement whichever server was connected:

CREATE USER 'name'@'%'
  IDENTIFIED WITH caching_sha2_password BY 'password'

MariaDB rejects that outright, and not only for that plugin. Verified against MariaDB 11 and MySQL 8:

Server Clause Result
MariaDB 11 IDENTIFIED WITH caching_sha2_password BY 'pw' ERROR 1064
MariaDB 11 IDENTIFIED WITH mysql_native_password BY 'pw' ERROR 1064
MariaDB 11 IDENTIFIED VIA mysql_native_password USING PASSWORD('pw') ok
MariaDB 11 IDENTIFIED BY 'pw' ok
MySQL 8 IDENTIFIED WITH caching_sha2_password BY 'pw' ok

So creating a user against MariaDB failed every time, whichever plugin was chosen. And caching_sha2_password — the dialog's default — isn't merely spelled differently there; MariaDB doesn't implement it. Its active authentication plugins are mysql_native_password, mysql_old_password and unix_socket.

The fix

The statement now depends on the server. serverFlavour reads the version string the connection already carries — the same question the backend asks for EXPLAIN ANALYZE.

  • MariaDB → IDENTIFIED VIA <plugin> USING PASSWORD(...)
  • MySQL → IDENTIFIED WITH <plugin> BY ...
  • Either, plugin left as "Server default" → plain IDENTIFIED BY ...

"Server default" is now the default, because it's the only form that's right on both.

The plugin list is per-server too. Offering caching_sha2_password on MariaDB would only move the failure from parse time to execution time.

WITH MAX_USER_CONNECTIONS and ACCOUNT LOCK were never the problem — both servers take them. Worth recording, since they sit in the same statement and could easily have been assumed guilty by association.

Statement building moves out of the component into src/lib/admin/create-user.ts, where it can be tested without rendering a dialog.

Tests

13 unit tests on the builder and flavour detection.

4 integration tests doing the half unit tests can't — each server accepting the form built for it, both accepting the portable one, and one that pins the defect rather than trusting the fix: MariaDB still rejecting the form that was being sent. If that ever passes, the branch can go.

One honest note: the unit tests are new code testing new code, so they don't "fail against the previous version" the way a regression test does. The integration tests are what actually demonstrate the bug and the fix.

16 admin integration tests green against live MySQL 8 and MariaDB 11; 1819 unit + 303 browser; clippy/tsc/dprint/eslint clean.

🤖 Generated with Claude Code

Closes #561.

The dialog emitted the same statement whichever server was connected:

    CREATE USER 'name'@'%'
      IDENTIFIED WITH caching_sha2_password BY 'password'

MariaDB rejects that outright, and not only for that plugin. Verified
against MariaDB 11 and MySQL 8:

    MariaDB  IDENTIFIED WITH caching_sha2_password BY 'pw'   ERROR 1064
    MariaDB  IDENTIFIED WITH mysql_native_password BY 'pw'   ERROR 1064
    MariaDB  IDENTIFIED VIA mysql_native_password USING PASSWORD('pw')   ok
    MariaDB  IDENTIFIED BY 'pw'                              ok
    MySQL 8  IDENTIFIED WITH caching_sha2_password BY 'pw'   ok

So creating a user against MariaDB failed every time, whichever plugin was
chosen. caching_sha2_password — the dialog's default — is not merely spelled
differently there; MariaDB does not implement it. Its active authentication
plugins are mysql_native_password, mysql_old_password and unix_socket.

The statement now depends on the server. serverFlavour reads the version
string the connection already carries, the same question the backend asks
for EXPLAIN ANALYZE. MariaDB gets IDENTIFIED VIA ... USING PASSWORD(...),
MySQL keeps IDENTIFIED WITH ... BY, and both get plain IDENTIFIED BY when
the plugin is left as Server default — which is now the default, because it
is the only form that is right on both.

The plugin list is per server too. Offering caching_sha2_password on MariaDB
would only move the failure from parse time to execution time.

WITH MAX_USER_CONNECTIONS and ACCOUNT LOCK were never the problem; both
servers take them, which is worth recording since they sit in the same
statement.

Building the statement moves out of the component into
src/lib/admin/create-user.ts, where it can be tested without rendering a
dialog.

Thirteen unit tests. Four integration tests do the half unit tests cannot:
each server accepting the form built for it, both accepting the portable
one, and — pinning the defect rather than trusting the fix — MariaDB still
rejecting the form that was being sent. If that last one ever passes, the
branch can go.

The unit tests are new code testing new code, so they do not fail against
the previous version in the way a regression test would. The integration
tests are what actually demonstrate the bug and the fix.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit eaf798a into main Sep 8, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/admin-mariadb-create-user branch September 8, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][bug] Create User is a syntax error on MariaDB — the plugin clause it emits is MySQL-only

1 participant