MariaDB – Importing Old MySQL Database Dump into Docker Container Fails

dockermariadbMySQL

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.

Thanks!

Best Answer

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).