I'm trying to import an older (~version 5) server into a MariaDB docker container.

I created a dump using the mysqldump command (with --all-databases), and when I try to import it I get the following error:

ERROR 1050 (42S01) at line 2071: Table 'user' already exists

I'm trying to import into a brand new container, using the standard command:

 mysql -uroot -p  < [sqldump].sql

I'm a novice when it comes to SQL and was wondering if I'm missing something obvious, or if there is some real incompatibility.

I'd really appreciate your advice.


  • Delete the existing user table?
    – Bert
    Dec 24 '20 at 17:20
  • I tried, but it doesn't really exist. I still went through with the whole thing (drop, flush and commit) to no avail...
    – dkd6
    Dec 24 '20 at 17:27

It sounds like your dump script wants to overwrite the system "mysql" database that contains users and privilege information. If that's really what you want to do, you can run mysqldump again with the --add-drop-database option, then FLUSH PRIVILEGES after import. I wouldn't recommend that though, especially if the databases are running different versions.

A better option would be to explicitly choose which databases you want to export by passing their names to the --databases argument, excluding DBs like "mysql", "information_schema" and "performance_schema". You would then grant privileges to the newly imported DBs as needed.

Another quick option would be to edit your existing dump file in a text editor and just take out the part that wants to create the "mysql" tables (including "user" and others).

  • It sounds like the dump is not the same version as the target system? In that case there may be modifications to the mysql table schemas that would lead to trouble. So, do not reload mysql or information_schema or performance_schema or sys.
    – Rick James
    Dec 25 '20 at 18:21
  • THANK YOU, @Google Fail! I was attempting to "restore" a complete database dump from mysqld Ver 5.7.33-0ubuntu0.16.04.1 to mariadb Ver 15.1 Distrib 10.5.9-MariaDB and am glad I heeded your A better option would be... advice. Otherwise I would have "restored" user and several other tables in forms not compatible with my target database engine.
    – CODE-REaD
    Apr 2 at 16:50
  • You’re welcome! @CODE-REaD Apr 2 at 16:56

The issue has nothing to do with Docker and probably doesn't belong under serverfault. The answer is here: https://dba.stackexchange.com/a/285253/93071

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.