Cannot move to MySQL Database

ss884 years ago

Hello Anton,

I am trying to connect my server traccar to a MySQL database which i have installed on my Windows 10 OS.
I have the server running from the code and access the interface with localhost:8082.
But data are being saved somewhere not in my MySQL database (probably in the already set H2) eventhough i set the configuration of MySQL as described in the documentation (https://www.traccar.org/mysql/) in the conf files : traccar/setup/traccar.xml & traccar-web/conf/traccar.xml like so :

<entry key='database.driver'>com.mysql.jdbc.Driver</entry>
    <entry key='database.url'>jdbc:mysql://localhost:3306/traccar?serverTimezone=UTC&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'>pw</entry> 

What's the problem with this config ?
Thank you.

hceccacci4 years ago

You are not using the correct configuration as recommended.

This is what in the documentation:

<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://[HOST]:3306/[DATABASE]?serverTimezone=UTC&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'>[USER]</entry>
<entry key='database.password'>[PASSWORD]</entry>

Take a look there:
https://www.traccar.org/mysql/

ss884 years ago

I used instead of

 com.mysql.cj.jdbc.Driver
this driver
 com.mysql.jdbc.Driver
but other than that it is exactly as in the DB config page and it's not affecting the storage process of my server in any way.

ss884 years ago

By the way if i remove the entry of H2 in the config of databases and add nothing, my server still get and post data i don't know how.

ss884 years ago

It is like no effect is taking place if i alter the setup/traccar.xml server file

ss884 years ago

@hceccacci your config is also wrong with & not escaped character.

hceccacci4 years ago

@ss88 I checked my production environment and found this configuration:

    <entry key='database.driver'>com.mysql.jdbc.Driver</entry>
    <entry key='database.url'>jdbc:mysql://localhost:3306/[DATABASE]?serverTimezone=UTC&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'>[USER]</entry>
    <entry key='database.password'>[PASSWORD]</entry>
ss884 years ago

@hceccacci alright thanks for the clarification.
Regards.

Anton Tananaev4 years ago

Traccar uses the database from the config file. There is no other place. So, if it still doesn't work, you'll have to double check everything on your end. Also remember to restart the service after any config change.