I’ve got MySQL set up as my persistence, but it’s continuing to fail. I’ve read through all the threads that have to do with MySQL and haven’t seen a solution yet that has helped me, hopefully you can help.
2016-01-27 21:58:34.310 [ERROR] [.p.m.i.MysqlPersistenceService] - mySQL: Failed connecting to the SQL database using: driverClass=com.mysql.jdbc.Driver, url=jdbc:mysql://192.168.1.39:3306/openhab, user=openhab, password=xxxxx
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
It may be that your MySQL server is only listening for connections on the loopback address (127.0.0.1). On my setup, which is the default as it was installed, I have this in /etc/mysql/my.cnf:
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
According to the manual, if you change it to 0.0.0.0, it will listen for connections on any interface, which will be needed if it’s running on a different machine. If instead it’s running on the same machine, you should be able to change openhab.cfg with this line:
Hi,
I found that the actual ip-adress was not working for me (I run mysql on the same machine as OpenHab).
I needed to change it to:
mysql:url=jdbc:mysql://localhost/OpenHab
(I even believe the input of the directory name was case sensitive).
Cheers
Björn
localhost is usually defined as 127.0.0.1, so that would be the same advice as I gave earlier. Good point about case sensitivity of the database name. My MySQL database is named openhab, so that is specific to one’s setup.
I actually started with 127.0.0.1/openhab and localhost (knowing they were the same thing, but sometimes it’s black magic), but that wasn’t working. I read some threads to include the port number, didn’t work. There was another thread indicating that sometimes if 127.0.0.1 doesn’t work, even if you’re on the same machine, specify the IP distinctly.
I used these instructions for creating the DB, so I’m betting it’s the case. Will try it and get back to you.
hi, i’ve been doing some tests and i think there’s a problem with openHAB (or maybe mysql…?):
In mysql config, i set up the local IP address 192.168.x.x
I did it because i need to connect to this mysql server from another IP in the same network (and that works OK).
I can access from command line to mysql and test mysql user ‘openhab’ without problems. Queries OK to the database. Can see table Items, etc
In openhab i changed from ‘localhost’ to the IP address, and still the same error:
mySQL: Failed connecting to the SQL database using: driverClass=com.mysql.jdbc.Driver, url=jdbc:mysql://192.168.x.x:3306/openhab, user=openhab, password=mypassword
And:
mySQL: No connection to database. Can not persist item …
To resume (this are my tests, maybe yours are different):