Migration vom MySQL (Azure) to MariaDB

Sven19 hours ago

Hi.
I've been struggling with a problem for four days now.
It shouldn't be a problem at all, as I've successfully completed the process several times over the past few years.

My Traccar runs in Docker - the database is on Microsoft AZURE ("Flexible Azure Database for MySQL Server"). Everything has been running smoothly for a long time - not a single Traccar update has ever caused any problems. My task now is to migrate the entire database from the aforementioned AZURE service to a MariaDB, which also runs in Docker.

I perform the following steps:

  1. Complete dump of the existing DB:
    mysqldump -h XXXXX.mysql.database.azure.com -u sven -p traccar > traccar_dump.sql

  2. Stop the Docker container "traccar"

  3. Adapt the traccar.xml to the new DB

  4. Create an empty DB "traccar" in the new MariaDB.
    4.1 Create a user with grant permissions for the "traccar" DB
    (same username and password as before on Azure)

--> From here, I tested various solutions. None worked - however, the error messages were different.

5.1 Importing the dump using
mysql -h XXX.YYY.ionos.com -u sven -p traccar < traccar_dump.sql

Then I restart the Docker container "traccar."
Traccar doesn't start. The log keeps showing:

ERROR: Main method error - Table 'tc_attributes' already exists - SQLSyntaxErrorException (... < DatabaseModule:99 < <gener:-1 < *:-1 < ... < MainModule:139 < <gener:-1 < ...)

My second option also fails:

5.2 Before importing the dump again, I restart the Docker container. Traccar starts immediately and creates all tables in the new database (MariaDB). I stop the container and try importing the dump again (same command as above in 5.1). Then I start the Docker container and traccar starts. My devices are visible with the last known location. As soon as I address one of them and it connects to Traccar, the following error repeatedly appears in the log (as long as the device is online):

INFO: [T026e539c] connected 2025-07-13 13:32:26
INFO: [T026e539c: h02 < 80.187.116.15] *HQ,9171089463,V1,113453,A,5048.1872,N,01256.8069,E,031.80,265,130725,FFFFBBFF,262,01,35120,551#
2025-07-13 13:32:26
WARN: [T026e539c] error - Cannot invoke "Object.getClass()" because "object" is null - NullPointerException (CacheKey:22 < CacheGraph:95 < CacheManager:291 < *:325 < *:164 < ConnectionManager:157 < ...)

I've run out of ideas for a solution and my rudimentary SQL knowledge. What am I missing? Am I stupid?

The most important thing: At the end of the day, I still have a complete and functioning Traccar installation. I simply retrieve my previous traccar.xml and restart the container – and everything runs smoothly again. In the next few weeks, however, I would like to move more and more of my services away from AZURE – also for cost reasons.
There's no rush, and no data loss has occurred. But I think I can't avoid asking the community and Anton for help...

Thank you & best regards,
Sven

Anton Tananaev11 hours ago

The first error likely indicates that you were missing some important tables in the database.

The second error means that you're missing some objects in the database. Basically broken references.