mysql connection is not working

ashvini8 years ago

Dear Sir,
I have change to database to mysql according traccar.com website but when i tried to save device info or register user then error come connection failed .

I put my mysql user and password.

Anton Tananaev8 years ago

Check logs to see what the error is.

aalamee8 years ago

Hi
I have a similar problem. I did all change in traccar.xml file according to https://www.traccar.org/mysql web page and add sql_mode="ANSI-QUOTES" to my.ini in xampp mysql ... but connection with database dose not establish. in log file exist this statment :

INFO|4840/0|Service traccar|16-12-06 00:11:50|Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

and finally:

INFO|wrapper|Service traccar|16-12-06 00:20:04|calling onStop
INFO|wrapper|Service traccar|16-12-06 00:20:04|Win service stop - timeout: 30000
INFO|wrapper|Service traccar|16-12-06 00:20:04|Win service wrapper.control -> stopping application
INFO|wrapper|Service traccar|16-12-06 00:20:04|Win service stop - after shutdown
INFO|wrapper|Service traccar|16-12-06 00:20:04|Win service stop - before notify
INFO|wrapper|Service traccar|16-12-06 00:20:04|Win service terminated

I run traccar on my server with H2 database very fine. But i want get traccar's data from another web application(ofcourse if it possible because maybe occur a confilct on port 3306) .
However i want traccar on mysql database first.
Please help me...
Thanks a lot..

Anton Tananaev8 years ago

Obviously some configuration parameters are incorrect, or MySQL is not configured to accept connection.

aalamee8 years ago

Hi dear anton
I creat a database: track and user: tracer with pass: gpsRFID .

This is traccar.xml content:

<properties>
        <entry key="config.default">./conf/default.xml</entry>

    <entry key='database.driver'>com.mysql.jdbc.Driver</entry> 
    <entry key='database.url'>jdbc:mysql://localhost:3306/track?allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
    <entry key='database.user'>tracer</entry> 
    <entry key='database.password'>gpsRFID</entry>
</properties>

and so any other change into my.ini configuration mysql file.

I try to connect traccar to mysql for about 4 days but !!!

Thank so much.

Anton Tananaev8 years ago

I would recommend to try any JDBC client with same connection parameters. As I said before, the issue is either with connection parameters, or with your MySQL database config. Without access to the server I can only guess what's wrong.

najeem8 years ago

I have been struggling with a similar problem for three days now without headway. My own error is 'localhost refused to connect' when I type localhost:8082. The installation process was successful. I changed the parameters as indicated for MySql with correct password and username.

Please, let those who have successfully configure for MySQL help us out.

Anton Tananaev8 years ago

@najeem, you should check logs for errors.

najeem8 years ago

This is what I have in my traccar log file.
Am I using the right Java version?

2016-12-17 12:40:20  INFO: Operating system name: Windows 10 version: 10.0 architecture: x86
2016-12-17 12:40:20  INFO: Java runtime name: Java HotSpot(TM) Client VM vendor: Oracle Corporation version: 25.111-b14
2016-12-17 12:40:20  INFO: Memory limit heap: 247mb non-heap: 0mb
2016-12-17 12:40:20  INFO: Character encoding: UTF-8 charset: UTF-8
2016-12-17 12:40:20  INFO: Version: 3.9-SNAPSHOT
2016-12-17 12:40:47  INFO: Starting server...
2016-12-17 12:42:03  INFO: Operating system name: Windows 10 version: 10.0 architecture: x86
2016-12-17 12:42:03  INFO: Java runtime name: Java HotSpot(TM) Client VM vendor: Oracle Corporation version: 25.111-b14
2016-12-17 12:42:03  INFO: Memory limit heap: 247mb non-heap: 0mb
2016-12-17 12:42:03  INFO: Character encoding: UTF-8 charset: UTF-8
2016-12-17 12:42:03  INFO: Version: 3.9-SNAPSHOT
2016-12-17 12:42:24  INFO: Starting server...
2016-12-17 12:43:58  INFO: Operating system name: Windows 10 version: 10.0 architecture: x86
2016-12-17 12:43:58  INFO: Java runtime name: Java HotSpot(TM) Client VM vendor: Oracle Corporation version: 25.111-b14
2016-12-17 12:43:58  INFO: Memory limit heap: 247mb non-heap: 0mb
2016-12-17 12:43:58  INFO: Character encoding: UTF-8 charset: UTF-8
2016-12-17 12:43:58  INFO: Version: 3.9-SNAPSHOT
Anton Tananaev8 years ago

You are looking at the wrong log file.

carlosAguA8 years ago

Hi Mr. Anton or someone who may help me.

I´m trying to run the project using local database and I´m having problems with the mysql connection as well. What I´ve done sofar is:

  1. Downloaded from github the server file and then downloaded from github the webinterface to the folder where the server was downloaded.
  2. I created a database using HeidiSQL interface.
  3. I changed the file traccar.xml and it has the following lines :
<entry key="config.default">./conf/default.xml</entry> 
    <entry key='database.driver'>com.mysql.jdbc.Driver</entry> 
 <entry key='database.url'>jdbc:mysql://localhost:3306/traccar2?allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
 <entry key='database.user'>root</entry> 
 <entry key='database.password'>myroot84</entry>
  1. I´m building and running from netbeans like Build from netbeans.
  2. Opening localhost:8082 and registering user.

Overview:
I noticed that after doing so, a file within the project called "target" is created. Two of the files inside it are kind of the db files and I suppose they shouldn´t be created since now the traccar.xml has different configuration.

Problems

  1. I´m not able to see any table created in the database.
  2. In the file where the project is, there is just the tracker-server.log file but any wrapper.log file.
  3. What I see in the tracker-server.log is the same than najeem has.

I´ve been checking within the forum to see who was the same issue but I haven´t been able to solve it so far. By the way... (I uninstalled the traccar server 3.9> setup.exe, which was required for using it as a service before wanting to use my local database, since I assume that now everything will run from netbeans.

Thank you in advance!

Anton Tananaev8 years ago

If you run from console or IDE, instead of wrapper log file, you should get messages into standard output/console.

carlosAguA8 years ago

Thanks ! so the way to check that part is on the IDE. I got it.

What I´m able to see is :

------------------------------------------------------------------------
Building traccar 3.9-SNAPSHOT
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ traccar ---
[main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Started.
INFO 12/21/16 6:48 PM: liquibase: Clearing database change log checksums
INFO 12/21/16 6:48 PM: liquibase: Successfully acquired change log lock
INFO 12/21/16 6:48 PM: liquibase: Successfully released change log lock
INFO 12/21/16 6:48 PM: liquibase: Successfully acquired change log lock
INFO 12/21/16 6:48 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG
INFO 12/21/16 6:48 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG
INFO 12/21/16 6:48 PM: liquibase: ./schema/changelog-master.xml: changelog-3.8::changelog-3.8-dropuniquetoken::author: Change set changelog-3.8::changelog-3.8-dropuniquetoken::author failed, but failOnError was false.  Error: Constraint "UK_USER_TOKEN" not found; SQL statement:
ALTER TABLE PUBLIC.users DROP CONSTRAINT uk_user_token [90057-193] [Failed SQL: ALTER TABLE PUBLIC.users DROP CONSTRAINT uk_user_token]
INFO 12/21/16 6:48 PM: liquibase: Successfully released change log lock
[main] INFO org.eclipse.jetty.util.log - Logging initialized @4484ms
[main] INFO org.eclipse.jetty.server.Server - jetty-9.2.19.v20160908
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@7efe7b87{/api,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@3e104d4b{/console,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@64469d8{HTTP/1.1}{0.0.0.0:8082}
[main] INFO org.eclipse.jetty.server.Server - Started @7402ms
Anton Tananaev8 years ago

Looks like everything works fine. I guess you changed wrong config file. You should change the same file that you put as a command line argument.

carlosAguA8 years ago

According to the documentation he file´s name is traccar.xml for the project running windows operating system.

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

 <!--This is the main configuration file. All your configuration parameters should be placed in this file. Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues with upgrading to a new version. Parameters in the main config file override values in the default file. Do not remove "config.default" parameter from this file unless you know what you are doing. For list of available parameters see following page: https://www.traccar.org/configuration-file/-->

    <entry key="config.default">./conf/default.xml</entry> 
    <entry key='database.driver'>com.mysql.jdbc.Driver</entry> 
 <entry key='database.url'>jdbc:mysql://localhost:3306/traccar2?allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
 <entry key='database.user'>root</entry> 
 <entry key='database.password'>myroot84</entry>
</properties>

Should I add something else ? Maybe I´m completely lost thinking that only adding that would work.
If you have any clue about other thing I could change or modify just let me know.

Thanks.