I can’t seem to get mysql persistence working in OH2. I thought I’d set it up correctly, but I just get “No suitable driver found for url=jdbc:mysql://127.0.0.1:3306/openhab” in the log. Now when I look in mysql.config and jdbc.config the url is “url=jdbc:mysql://127.0.0.1:3306/openhab”, like an extra url= has sneaked in there. I changed it back and restarted entire openhab, but I still get the same error and when I look in the config files the url is changed back. Is this saved somewhere else as well or where is it coming from?
how does your mysql.cfg file look like? That’s mine:
# the database url like 'jdbc:mysql://<host>:<port>/<database>' (without quotes)
# the database user
# the database password
# the reconnection counter
# the connection timeout (in seconds)
# Use MySQL Server time to store item values (=false) or use openHAB Server time (=true).
# For new installations, its recommend to set "localtime=true".
# (optional, defaults to false)
This is really strange… the flat text config files (in /etc) should not be updated by openHAB 2…
Even if there is a another place (yes it is here: /var/lib/openhab2/config/org/openhab/mysql.config but you should not modify this one manually… it should be updated when you modify the /etc one) where the settings are stored and pulled into OH2 config, the /etc/openhab2/services/mysql.cfg (not mysql.config) file is in theory read-only for OH2.
Try deleting the existing file, create a new one and use another text editor to edit it (maybe something is wrong with that… just guessing)
Oh… Sorry… All my stupidity… I actually modified the file in /var/lib all this time, the file in /etc was still wrong. No wonder it didn’t work. Guess I must have changed the /etc one the first time and then forgot about it. Still a bit confusing with all the places. Welcome to my world…
edit: Just like to confirm, tables were now created in my openhab database, so the connection seems to work. One table named “items” and one named “Items”, wonder what the difference is
In general, remember that these files (in /var/lib/openhab2/) are composing your $userdata which are important when you want to create a backup (along with the configuration files in /etc/openhab2). You need them, but OH2 manages them (OH2 is Behind The Wheel)
I am using OH2 for the past 6 months and I never had to manually modify something there (only for advanced cases of troubleshooting).
I do take a regular backup of that folder because all my things (mainly Z-Wave) are discovered from Paper UI and are stored in the new /var/lib/openhab2/jsondb. Also, other configurations that you do from Paper UI and/or HABmin will go in files stored in subdirs of /var/lib/openhab2/