ERROR at line 1: Unknown command ‘-‘. is an error that occurs when you try to import a database exported from another web server via the command line. If you encounter this error while importing a database on MariaDB system, I hope the short guide below will help you.
In short, if you don't care why this error occurs, the solution is very simple. When importing the database into MariaDB it will add “--force
” to continue importing the .sql file via command line.
The import command line will look like this:
mariadb -u <user_db> -p -h localhost <name_db> --force < database.sql
The error "MariaDB Import ERROR at line 1: Unknown command '-'.
” is caused by compatibility issue. An additional patch was applied to the mariadb-dump utility, adding a command to the very beginning of the dump file, in a comment, to trigger sandbox mode. This command looks like this:
/*!999999\ - enable the sandbox mode */
The compatibility issue occurs because older versions of the MariaDB client and all versions of the MySQL client do not understand this command and will generate the error. So, if you import a dump from a new version of MariaDB into a version that does not have this patch or into a version of MySQL, you will experience this problem.
MariaDB Import ERROR at line 1: Unknown command '-'.
Related: Import .SQL File Error – MySQL server has gone away
The change was implemented in the following MariaDB versions: 10.5.25, 10.6.18, 10.11.8, 10.11.9, 11.0.6, 11.1.5, 11.2.4, and 11.4.2. If you export a dump file from these versions and try to import it into a non-updated version, you will encounter this error.