Skip to content

Add database client auto-detection and version matching#212

Merged
AaronFeledy merged 3 commits intomainfrom
db-client-config
Feb 18, 2026
Merged

Add database client auto-detection and version matching#212
AaronFeledy merged 3 commits intomainfrom
db-client-config

Conversation

@AaronFeledy
Copy link
Member

@AaronFeledy AaronFeledy commented Feb 17, 2026

Summary

Addresses MariaDB/MySQL client compatibility issues (lando/lando#3833) by detecting database services and installing matching clients for PHP 8.3+.

Changes

  • Auto-detection: Scans services for mysql:X.X or mariadb:X.X and installs the appropriate client
  • db_client config option: auto (default), false, or explicit type:version
  • Pre-downloaded MySQL clients: Both 8.0 and 8.4 binaries included in images
  • MariaDB wrappers: Creates mysqlmariadb wrappers to avoid deprecation warnings
  • Compatibility configs: Sets disable-ssl-verify-server-cert and skip-column-statistics

Version Mapping

Database Version Client Used
MySQL 8.3, 8.4 MySQL 8.4 client
MySQL 5.7, 8.0, 8.1, 8.2 MySQL 8.0 client
MariaDB 10.x, 11.x MariaDB client with wrappers

Testing

services:
  appserver:
    type: php:8.4
  database:
    type: mysql:8.4  # Client auto-detected

See examples/db-client/ for test scenarios.

Notes

  • Only applies to PHP 8.3+ (older versions keep default mariadb-client)
  • Requires image rebuild to include pre-downloaded MySQL binaries

Resolves #167,


Note

Medium Risk
Touches service build-step generation and Docker image contents; mistakes could break mysql/mysqldump availability or alter client behavior for PHP 8.3+ containers.

Overview
Adds database client auto-detection and installation for PHP 8.3+ services. builders/php.js now introduces a db_client option (default auto) that scans app services for mysql:*/mariadb:* and injects a root build step to install a matching client, with false to opt out or an explicit type:version override.

To support version-matched installs, PHP 8.3–8.5 image Dockerfiles now bundle pre-fetched MySQL 8.0 and 8.4 client binaries, and new helper scripts (install-db-client.sh, mysql-client-install.sh, mariadb-compat-install.sh) switch clients via symlinks/wrappers and write compatibility config. Docs and examples are updated, and example fixtures bump image tags from -6 to -7 plus a new examples/db-client scenario.

Written by Cursor Bugbot for commit 9b8084c. This will update automatically on new commits. Configure here.

@netlify
Copy link

netlify bot commented Feb 17, 2026

Deploy Preview for lando-php ready!

Name Link
🔨 Latest commit 9b8084c
🔍 Latest deploy log https://app.netlify.com/projects/lando-php/deploys/6995313de591d200086c06b3
😎 Deploy Preview https://deploy-preview-212--lando-php.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 84 (🟢 up 16 from production)
Accessibility: 98 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@AaronFeledy AaronFeledy changed the title feat: add database client auto-detection and version matching Add database client auto-detection and version matching Feb 18, 2026
@AaronFeledy AaronFeledy marked this pull request as ready for review February 18, 2026 02:59
@cursor
Copy link

cursor bot commented Feb 18, 2026

Bugbot Autofix prepared fixes for 2 of the 2 bugs found in the latest run.

  • ✅ Fixed: MariaDB wrapper script generates wrong command names
    • Added hyphen separator in command name generation to produce correct MariaDB binary names like mariadb-dump instead of mariadbdump.
  • ✅ Fixed: Auto-detection returns wrong client in multi-database test
    • Added explicit db_client: mysql:8.4 to php-mysql84 service to ensure correct client selection instead of relying on global auto-detection.

View PR

Or push these changes by commenting:

@cursor push a328c4043c
Preview (a328c4043c)
diff --git a/examples/db-client/.lando.yml b/examples/db-client/.lando.yml
--- a/examples/db-client/.lando.yml
+++ b/examples/db-client/.lando.yml
@@ -5,6 +5,7 @@
   php-mysql84:
     type: php:8.4
     via: cli
+    db_client: mysql:8.4
 
   mysql84:
     type: mysql:8.4

diff --git a/scripts/mariadb-compat-install.sh b/scripts/mariadb-compat-install.sh
--- a/scripts/mariadb-compat-install.sh
+++ b/scripts/mariadb-compat-install.sh
@@ -9,7 +9,8 @@
 
 # Create wrapper scripts for each mysql* command that maps to mariadb* equivalent
 for cmd in mysql mysqldump mysqladmin mysqlcheck mysqlimport mysqlshow; do
-  mariadb_cmd="mariadb${cmd#mysql}"
+  suffix="${cmd#mysql}"
+  mariadb_cmd="mariadb${suffix:+-}${suffix}"
 
   if command -v "$mariadb_cmd" &> /dev/null; then
     cat > "/usr/local/bin/$cmd" << EOF

cursoragent and others added 2 commits February 17, 2026 21:23
- Fix mariadb-compat-install.sh to use hyphens in command names (mariadb-dump instead of mariadbdump)
- Add explicit db_client: mysql:8.4 to php-mysql84 test service to avoid auto-detection issues in multi-database environments
@AaronFeledy AaronFeledy merged commit fc4f061 into main Feb 18, 2026
33 of 66 checks passed
@AaronFeledy AaronFeledy deleted the db-client-config branch February 18, 2026 03:27
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before Autofix could start.


[mysqldump]
# Prevent column-statistics errors with newer mysqldump
skip-column-statistics
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MariaDB config breaks mysqldump with unknown option

High Severity

The [mysqldump] section containing skip-column-statistics is written to lando.cnf by the MariaDB compat script. MariaDB's mariadb-dump tool reads this section (for backward compatibility with [mysqldump]) but does not recognize skip-column-statistics, which is a MySQL 8.0-only option. This causes mariadb-dump (and the mysqldump wrapper) to fail with an "unknown variable" error, breaking mysqldump for all MariaDB setups — the exact scenario the PR aims to fix.

Fix in Cursor Fix in Web

COPY --from=mysql-client-80 /usr/bin/mysqladmin /usr/local/mysql-client/8.0/mysqladmin
COPY --from=mysql-client-84 /usr/bin/mysql /usr/local/mysql-client/8.4/mysql
COPY --from=mysql-client-84 /usr/bin/mysqldump /usr/local/mysql-client/8.4/mysqldump
COPY --from=mysql-client-84 /usr/bin/mysqladmin /usr/local/mysql-client/8.4/mysqladmin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied MySQL binaries lack required shared library dependencies

High Severity

The COPY --from=mysql-client-80 and COPY --from=mysql-client-84 directives copy only the MySQL client binaries without their required shared libraries (notably libmysqlclient.so.21/.so.22). These binaries are dynamically linked and will fail at runtime with "cannot open shared object file" errors. The PHP image only has MariaDB's libmariadb.so.3 (from mariadb-client), which is not ABI-compatible with MySQL's libmysqlclient. The mysql-client-install.sh warning fallback (mysql --version || echo ...) masks this during build, but the feature is completely non-functional at runtime.

Additional Locations (2)

Fix in Cursor Fix in Web

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.

Updating recipe with mysql database to PHP 8.4 causes mysql command errors

2 participants