"Unable to connect to ZM db.SQLSTATE[HY000] [2002] Connection refused"

Support for the docker image maintained by dlandon
Post Reply
jb2017
Posts: 11
Joined: Tue Oct 31, 2017 2:11 pm

"Unable to connect to ZM db.SQLSTATE[HY000] [2002] Connection refused"

Post by jb2017 »

Hello,

I've been using the dlandon/zoneminder docker for a while now. This is running on arch linux, on a zfs pool. Twice now it's got into a situation where if I try to go the web interface then my browser just shows ...

Code: Select all

Unable to connect to ZM db.SQLSTATE[HY000] [2002] Connection refused
The first time this happened was following a number of other unrelated troubleshooting events ... I may have done a hard reset on the machine followed by a system update, and I remember having to rollback the zoneminder zfs dataset to a previous snapshot. It worked after the rollback. My suspicion at the time was that the DB had somehow got corrupted.

Now it's happened a second time, but this time there have been no hard resets, or anything like that. The system has been running stable for a while, and I've been too busy with work to run any system updates recently ... so I feel that something else has caused this latest instance of the issue.

Here's the tail end of my Zoneminder docker log ...

Code: Select all

Starting services...
 * Starting Apache httpd web server apache2
 * 
 * Starting MariaDB database server mysqld
   ...fail!
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/ZoneMinder/Config.pm line 96.
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 147.
Compilation failed in require at /usr/bin/zmupdate.pl line 73.
BEGIN failed--compilation aborted at /usr/bin/zmupdate.pl line 73.
Jul  4 20:40:03 0960cbebb361 zmupdate[1081]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) error val:]
Jul  4 20:40:03 0960cbebb361 zmupdate[1081]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) error val:]
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
Jul  4 20:40:03 0960cbebb361 zmupdate[1083]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) error val:]
Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/ZoneMinder/Config.pm line 96.
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 147.
Compilation failed in require at /usr/bin/zmupdate.pl line 73.
BEGIN failed--compilation aborted at /usr/bin/zmupdate.pl line 73.
Jul  4 20:40:03 0960cbebb361 zmupdate[1083]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) error val:]
Starting ZoneMinder:
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
Jul  4 20:40:03 0960cbebb361 zmpkg[1093]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) error val:]
Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/ZoneMinder/Config.pm line 96.
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 147.
Compilation failed in require at /usr/share/perl5/ZoneMinder.pm line 33.
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder.pm line 33.
Compilation failed in require at /usr/bin/zmpkg.pl line 34.
BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 34.
Jul  4 20:40:03 0960cbebb361 zmpkg[1093]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) error val:]
ZoneMinder failed to start

*** /etc/my_init.d/40_firstrun.sh failed with status 255

*** Killing all processes...
Jul  4 20:40:03 0960cbebb361 syslog-ng[20]: syslog-ng shutting down; version='3.25.1'
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/05_set_the_time.sh...
*** Running /etc/my_init.d/06_set_php_time.sh...
*** Running /etc/my_init.d/07_set_dri_permissions.sh...
Granting permissions on /dev/dri/* devices...
*** Running /etc/my_init.d/10_syslog-ng.init...
[2022-07-04T20:40:05.506391] WARNING: With use-dns(no), dns-cache() will be forced to 'no' too!;
Jul  4 20:40:05 0960cbebb361 syslog-ng[20]: syslog-ng starting up; version='3.25.1'
*** Running /etc/my_init.d/20_apt_update.sh...
Performing updates...
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://ppa.launchpad.net/iconnor/zoneminder-1.34/ubuntu focal InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:6 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages have been kept back:
  libegl-mesa0 libgbm1 libgl1-mesa-dri libglapi-mesa libglx-mesa0
  mesa-va-drivers mesa-vdpau-drivers mesa-vulkan-drivers php-apcu php-mysql
  php5.6-apcu php7.0-apcu php7.1-apcu php7.2-apcu php7.3-apcu php7.4-apcu
  php8.0-apcu
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
*** Running /etc/my_init.d/30_gen_ssl_keys.sh...
using existing keys in "/config/keys"
*** Running /etc/my_init.d/40_firstrun.sh...
Using existing conf folder
File zm.conf already copied
Error: Cannot download the ES server bundle
File zmeventnotification.ini already moved
File secrets.ini already moved
File opencv.sh already moved
File debug_opencv.sh already moved
Event notification server already moved
Pushover api already moved
Using existing ssmtp folder
Using existing mysql database folder
Copy /config/control/ scripts to /usr/share/perl5/ZoneMinder/Control/
Copy /config/conf/ scripts to /etc/zm/conf.d/
Creating symbolink links
usermod: no changes
usermod: no changes
usermod: no changes
Using existing data directory for events
Using existing data directory for images
Using existing data directory for temp
Using existing data directory for cache
no crontab for root
Seems to be a mysql DB issue ... but I wouldn't know where to start fixing this. My Zoneminder docker stores it data in a separate zfs dataset. I tried stopping Zoneminder, emptying that data dataset, and then starting Zoneminder again to force it to generate fresh new database etc ... but this also did not work.

Anybody got any ideas?
Post Reply