Fixing MariaDB Dump In Lando

MariaDB released a change that breaks importing database dumps that were made from an updated database.

The change was made for security reasons, but is causing some disruption for developers.

Read more about it here: https://mariadb.org/mariadb-dump-file-compatibility-change/

Updating MaraDB In Lando

At this time, Lando does not support any version of MariaDB that contains the fix.

MariaDB 11.4.2 was recently released by Bitnami on Docker Hub.

Here is an issue for updating MariaDB in Lando: https://github.com/lando/mariadb/issues/59.

However, that is currently not working entirely with Drush. It still throws an error as if it's not using the new version, although Lando says it's installed.

There is a drush issue for this, but it has been closed: https://github.com/drush-ops/drush/issues/6027.

Using a plugin development branch

Lando plugins are stored in ~/.lando/plugins/@lando.

To use a git branch (IE https://github.com/mortona42/mariadb), use git init to create a repo inside the plugin directory.

Use git remote add origin git@github.com:mortona42/mariadb, and git checkout main --force to get the code.

If you're using the drupal recipe, edit ~/.lando/plugins/@lando/drupal/builders/drupal-mariadb.js, and change the path to ./../../mariadb/builders/mariadb.js. (Otherwise it will use a version downloaded with NPM.)

Using --extra-dump with site aliases

Since the MariaDB update isn't working yet, we can use the workarounds from: https://github.com/drush-ops/drush/issues/6027#issuecomment-2212310987

Here is a lando site alias that will automatically remove the sandbox line in the dump:

lando:
  root: /app/web
  uri: https://mysite.lndo.site
  command:
    sql:
      sync:
        options:
          extra-dump: " | awk 'NR==1 {if (/enable the sandbox mode/) next} {print}'"

For some reason, this works with lando drush sql-sync, but not with the db-sync tooling set up here: https://www.drupalarchitect.info/tips/add-db-sync-command-lando

This can be fixed by adding the extra dump line to the tooling:

tooling:
  db-sync:
    service: appserver
    cmd: site=${0} && drush sql-sync @mysite.${site} @mysite.lando --extra-dump=" | awk 'NR==1 {if (/enable the sandbox mode/) next} {print}'"

It's Fixed In DDEV

Fixed in June 2024: https://ddev.com/blog/mariadb-dump-breaking-change/

Is Lando behind the curve?