Traccar MariaDB

Andrew Cumming3 years ago

Try entering your synology IP into the config as per

<entry key='database.url'>jdbc:mysql://192.168.1.112: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>

As Anton said, localhost in the container is likely not localhost on the host (mine wasnt but I'm using 2 containers on a Synology NAS).

Jérôme3 years ago

Same error with :

<entry key='database.url'>jdbc:mysql://192.168.1.100:3306/traccar?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
Anton Tananaev3 years ago

I think you have to use the bridge ip address of your host.

Jérôme3 years ago

Same error with :

<entry key='database.url'>jdbc:mysql://172.17.0.1:3306/traccar?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
Andrew Cumming3 years ago

can you connect to your mysql from outside of your NAS ?

Do you have the firewall on the synology enabled (if you do you may need to open the port).

Anton Tananaev3 years ago

And also check if your database is configured to accept remote connection, which is usually not the default.

Jérôme3 years ago

I don't know how to test my connection from the outside, however via PhpMyadmin it works and I don't know how to check if it's authorized from the outside :(

Jérôme3 years ago

I checked Enable TCP/IP connection on port 3306.

Domain socket /run/mysqld/mysqld.sock

Andrew Cumming3 years ago

on your synology, with root access, you should be able to connect to your mysql using

mysql -h 127.0.0.1  -p

enter your password, then enter

show grants;

you should get something like

MariaDB [(none)]> show grants;
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@%                                                                                                              |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `root`@`%` IDENTIFIED BY PASSWORD '*11DAC36CE958157AC76A321FFB7EFCFF9E74ABE0' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)

in the above, the 'root'@'%' the '%' part says you can connect from any IP. Typically by default it has something like 'root'@'localhost'

you may be able to enter

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
FLUSH PRIVILEGES;

the above should grant access from any IP for user root with the password you specify.

Andrew Cumming3 years ago

in the above, it should be GRANT ALL PRIVILEGES ON . TO it seemed to remove the . from it

Jérôme3 years ago

Here is what I get:

root@Onehebergeur:/volume1/@docker/aufs/diff/9f6c4f6e7c031b8e23b7206f16f2ae180709d8ccb88e52ef7e02fc63112e67a3/opt/traccar/conf# mysql -h 127.0.0.1 -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 246
Server version: 10.3.32-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
Jérôme3 years ago
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements: [Minimal password length 10, Include mixed case, Include numeric characters, Include special characters, Exclude common password]
MariaDB [(none)]>
Andrew Cumming3 years ago

You need to enter the command

show grants;

in the previous post, it should be GRANT ALL PRIVILEGES ON *.* TO it seemed to remove the *.* from it (I had to escape them)

also, in the command change PASSWORD to your own value or the password will be PASSWORD

Sorry for the delayed response. Its taking a while to respond as the forum is limiting the frequency of my responses.

I may leave it till tomorrow as its getting late here (after 10:30pm).

You may be able to find what you need here https://rtcamp.com/tutorials/mysql/remote-access/

Jérôme3 years ago
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'XXXXXXXXXXXXXXXXX' WITH GRANT OPTION;
Query OK, 0 rows affected (0.052 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.022 sec)

MariaDB [(none)]> show grants;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED BY PASSWORD '*69F1020DA0AA6BB7B952D6639AA86E12FBA26501' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION                                                                          |
+----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
Andrew Cumming3 years ago

I dont know why both lines have 'root'@'localhost' in them. One should have had 'root'@'%'

Both lines look like they will only allow localhost to connect to them which would prevent a container from connecting to it.

I think you'll need to look at that link I sent you and try to get an entry with 'root'@'%' listed.

It may also be possible that you might have to exit mysql then go back in to see the new privileges with the "show grants;" command.