mySQL: Connection is not valid!

Latey I’ve been seeing this mysql error (below) in my openhab.log, I restarted openhab2 and after about 2 hours it re-occurred, is this normal?
I’ve tried a few combinations in my mysql.cfg but not sure if the default is good or there is something else going on here.

[ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Connection is not valid!
[ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Error count exceeded 1. Disconnecting database.

maybe… some stale configs exist in your system…

post the contents of the following 2 files

/etc/openhab2/persistence/mysql.cfg
/var/lib/openhab2/config/org/openhab/mysql.config
1 Like

not sure if you meant my services file
/etc/openhab2/services/mysql.cfg

# the database url like 'jdbc:mysql://<host>:<port>/<database>' (without quotes)
url=jdbc:mysql://localhost/OpenHAB

# the database user
user=openhab

# the database password
password=****

# the reconnection counter
reconnectCnt=1

# the connection timeout (in seconds)
waitTimeout=28800

# 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)
localtime=true

cat /var/lib/openhab2/config/org/openhab/mysql.config

localtime="true"
password="****"
reconnectCnt="1"
service.pid="org.openhab.mysql"
url="jdbc:mysql://localhost/OpenHAB"
user="openhab"
waitTimeout="28800

"

true…

I don’t see anything wrong with the config files…

someone else increased the timeout: check -> Problems with mysql persistance, frequent connection failures

@mtrax

Hello, what’s your hardware, please?

I’m running on a Quad core intel box with 4Gb RAM using Ubuntu 16.04 LTS

I had the same problem on a pi a long time ago but your hardware should be able to handle that no problems.
Have your tried to clear your OH cache?