Sync Script: Fix for "ERROR at line 1: Unknown command '\-'."

When running the sync script from a source DB with an updated version of MariaDB to an outdated version, you’ll receive the following error:

ERROR at line 1: Unknown command '\-'.

This is due to a MariaDB dump file compatibility change. Essentially, if you’re syncing from a MariaDB version newer than 10.5.25, 10.6.18, 10.11.8, 11.0.6, 11.1.5, 11.2.4 and 11.4.2 to an older version, you’ll receive this error.

There are two options here:

  1. Update the destination MariaDB version.
  2. Add | tail +2 before each wp import command in the “Syncing database…” section of the script.

For example:

wp "@$FROM" db export --default-character-set=utf8mb4 - | tail +2 | wp db import - &&

This removes the new sandbox mode trigger (/*!999999\- enable the sandbox mode */) from the top of the dump at the time of import.

6 Likes

I encountered the same issue yesterday, but had not looked further into it.
Thanks!

1 Like

Additional notes and observations:

  • wp CLI uses the mysql client on the server system on which the WordPress site runs for queries (and also importing SQL dumps), not on the client, when using wp over SSH.
  • A MariaDB server of a version where the client of same version is affected by this bug can export a SQL dump that causes the issue. The client must be updated to a newer version than the server then (notably currently with Trellis on Ubuntu LTS).
  • SELECT VERSION(); shows the server version, not the client version which can still have the incompatibility.
  • On a development Docker container, for installing a recent version of mysql client that have the incompatibility patched, I had to install the mariadb-client package from the upstream MariaDB repository (not from stock Debian of Docker base image).
    Command used for the Docker image:
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- --mariadb-server-version="mariadb-11.2"
apt update
apt install -y mariadb-client
2 Likes