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:
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:
(I even believe the input of the directory name was case sensitive).
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.