Issue Switching from H2 to MySQL Database in Traccar

Malien76 months ago

Hello,
I am trying to set up Traccar with a MySQL database instead of the default H2 database. I downloaded the Traccar builder source using the following command:

git clone --recursive https://github.com/traccar/traccar.git

I modified the traccar.xml file to switch from H2 to MySQL by changing the database configuration as follows:

<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://localhost:3306/traccar?zeroDateTimeBehavior=round&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
<entry key='database.user'>root</entry>
<entry key='database.password'></entry>

However, when I run the program, the console shows the following log messages, which seem to indicate that it is still using the H2 database:

2024-06-11 11:40:29  INFO: HikariPool-1 - Added connection conn0: url=jdbc:h2:./target/database user=SA
2024-06-11 11:40:29  INFO: HikariPool-1 - Start completed.
2024-06-11 11:40:29  INFO: Set default schema name to PUBLIC
2024-06-11 11:40:29  INFO: Clearing database change log checksums
2024-06-11 11:40:30  INFO: Successfully acquired change log lock
2024-06-11 11:40:30  INFO: Successfully released change log lock
2024-06-11 11:40:33  INFO: Reading from PUBLIC.DATABASECHANGELOG
2024-06-11 11:40:33  INFO: Reading from PUBLIC.DATABASECHANGELOG

When I check the Traccar database on my local machine, it is empty.
Could anyone guide me on how to configure Traccar to use MySQL correctly? I would greatly appreciate any help.
Thank you!
Malien

Anton Tananaev6 months ago

It doesn't look like you changed the right config.

Malien76 months ago

Hi Anton,
Thank you for your quick reply. I have already changed the config file under Trackcar -> setup -> traccar.xml. Could you please guide me on which config file I need to change instead?
Thanks,
Malien

Anton Tananaev6 months ago

Are you running it from the source code? You have to provide full context of your setup.

Malien76 months ago

Thanks, Anton. After changing the debug.xml file, it works.