How to install and configure TRACCAR mysql database?

lokalsat8 years ago

Hello, can anyone give me a tutorial on how to install and configure the mysql database Traccar using the Ubuntu terminal?

nahuel7 years ago

Could you solve it?

cuwid6 years ago

Here's my step by step command to install traccar on ubuntu with mysql database

user@server:~$ sudo apt-get install default-jre
user@server:~$ sudo apt-get install mysql-server
user@server:~$ mysql -u root -p
mysql> CREATE DATABASE [database name for traccar];
mysql> CREATE USER '[mysql database user]'@'localhost' IDENTIFIED BY '[password]';
mysql> GRANT ALL PRIVILEGES ON [database name for traccar].* TO '[mysql database user]'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
(i asume that traccar source is on /usr/src folder)
user@server:~$  cd /usr/src/
user@server:/usr/src$ sudo apt-get install zip
user@server:/usr/src$ sudo unzip traccar-linux-4.0.zip
user@server:/usr/src$ sudo ./traccar.run
user@server:/usr/src$ sudo nano /opt/traccar/conf/traccar.xml
(on this step, just follow the instruction from https://www.traccar.org/mysql/)
user@server:/usr/src$ sudo /opt/traccar/bin/startDaemon.sh

Finish.
Your system is ready to use. Hope it help.

Adrian Hodgson6 years ago

A thank you to @cuwid. I know this started as an old post but I have just used this to start a new mysql database on my very small test server with ubuntu. I am learning so this was very good to find to get it up and running.

Adrian

Piotr1116 years ago

Without information from the @cuwid post, https://www.traccar.org/mysql/ looks incomplete.

juan cruz5 years ago

Keep in mind that after 4.1 to starte the service is: sudo systemctl start traccar.service

Nikko3 years ago

hello everyone, I'm using traccar with the default database and I decided to migrate to mysql, I followed all the steps but apparently it doesn't create the tables automatically and I can't make it work, I already installed mysql, created a user and assigned a password, Also check to have created a database.

Igor3 years ago

UP!
Same problem, mysqldb doesn't create the tables automatically

2022-05-21 21:37:20  INFO: HikariPool-1 - Starting...
2022-05-21 21:37:26 ERROR: HikariPool-1 - Exception during pool initialization. - Public Key Retrieval is not allowed - UnableToConnectException (... < DataManager:131 < *:90 < Context:298 < Main:120 < ...)
2022-05-21 21:37:26 ERROR: Main method error - Public Key Retrieval is not allowed - UnableToConnectException (... < DataManager:131 < *:90 < Context:298 < Main:120 < ...)
Anton Tananaev3 years ago

You have a problem with the database connection, as the error message indicates.

Igor3 years ago

Installed from wiki:
/opt/traccar/conf/traccar.conf

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

Create DB

mysql -u root -p
create database traccarDB character set utf8 collate utf8_bin;
create user traccar@localhost identified by 'traccarPASS';
grant all privileges on traccarDB.* to traccar@localhost;
flush privileges;
quit;

So, any advice?

Anton Tananaev3 years ago

There's a bunch of topic with exactly the same error as yours. You can get some suggestions from there.

Igor3 years ago

I take the installation instructions from the documentation. mysql, phpmyadmin, zabbix work properly. Traccar, which is installed by a script, edited in the config in 4 lines, causes problems. Go look for errors that are not described in the logs. Aw, you're in luck.

Anton Tananaev3 years ago

Have you tried adding allowPublicKeyRetrieval=true?

Igor3 years ago

I didn't do anything...but it worked, coincidence? I connected to the db through the user through the command line to make sure about the rights. Displayed a list of all tables and saw that they appeared. A very strange situation. Thanks for the recommendation. It remains to figure out how to migrate from h2 to mysql

Igor3 years ago

Anton, I have a question for you. The server does not turn on by itself. After restarting, only after I manually print on command line log in

mysql -u traccar -p traccarPASS

under the Traccar DB account, does it work. Can be corrected?