mysql conversion error

go2 years ago

Several years ago I successfully converted an older version of traccar server to use mysql, now I am working on a new installation on a new server and getting errors. The server stops and starts with the original /opt/traccar/conf/traccar.xml file, using systemctl stop traccar and systemctl start traccar

With my modified traccar.xml, it fails to start. Errors from log included here.

This is on CentOS 7 with mysql 5.5.68-MariaDB MariaDB Server

Instructions from: https://www.traccar.org/mysql/

By default Traccar Server uses embedded H2 database. If you want to use MySQL database engine you need to replace following lines in configuration file:

<entry key='database.driver'>org.h2.Driver</entry>
<entry key='database.url'>jdbc:h2:/home/user/Documents/traccar/target/database</entry>
<entry key='database.user'>sa</entry>
<entry key='database.password'></entry>

Configuration parameters for MySQL (replace [HOST], [DATABASE], [USER], [PASSWORD] with appropriate values; for local database use "localhost" as HOST):

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

My non-working /opt/traccar/traccar.conf file:

    <entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
    <entry key='database.url'>jdbc:mysql:localhost:3306/traccar?serverTimezone=UTC+8&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>
netstat -tulpn | grep LISTEN | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      21251/mysqld

/opt/traccar/logs/tracker-server.log

2022-05-14 13:41:49 ERROR: Main method error - Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, jdbc:mysql:localhost:3306/traccar?serverTimezone=UTC+8&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode='' - RuntimeException (... < DataManager:131 < *:90 < Context:298 < Main:120 < ...)
2022-05-14 13:42:00  INFO: HikariPool-1 - Starting...
2022-05-14 13:42:01 ERROR: Main method error - Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, jdbc:mysql:localhost:3306/traccar?serverTimezone=UTC+8&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode='' - RuntimeException (... < DataManager:131 < *:90 < Context:298 < Main:120 < ...)

Did I miss something or is there possibly another issue?

Thanks, Mike

Anton Tananaev2 years ago

You did miss forward slashes in the URL. Why did you remove them?