Symptoms
-
The version of the target MariaDB server is not the latest.
-
When trying to restore a MariaDB database from Plesk GUI, the following error is shown:
ERROR at line 1: Unknown command ‘-’.
2024-05-22 10:14:14,042 [ERROR] ‘mysql’ finished with non-zero exit code: 1
Unable to flush stdout: Broken pipe -
Restoring from the command line, the following error is shown:
# [root@server]# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin db_user < /var/www/vhosts/example.com/database.sql
ERROR at line 1: Unknown command '\-'.
Cause
Starting with version 10.5, MariaDB introduced a "Sandbox mode" to address certain vulnerabilities (referenced as MDEV-21178). This mode is enabled by a comment at the beginning of the dump file:
/*!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.5.25-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: databasename
-- ------------------------------------------------------
-- Server version 10.5.25-MariaDB-deb11
This line causes older versions of MariaDB (pre-10.5) and MySQL clients to misinterpret the command, leading to the error. The MariaDB and MySQL clients strip the backslash and dash, executing an invalid command.
Resolution
Update the target MariaDB server to the latest version in the series, e.g. 10.11.7 to 10.11.8, according to this Help Center article: How to upgrade MySQL 5.5 to 5.6/5.7 or MariaDB 5.5 to 10.x on Linux
If it's not possible to upgrade MariaDB to a newer version, you can consider one of the following workarounds:
Refer to the following MariaDB external article: https://mariadb.org/mariadb-dump-file-compatibility-change/
Workarounds listed in the article can be used to manually create a valid database dump for the destination server, that can be manually imported later.
If the target server version is the latest in the series (e.g. 10.5.25, 10.11.8, etc.), update the package mariadb-client.
Comments
Please sign in to leave a comment.