Access denied for user 'www-data'@'localhost'

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
marcolino7
Posts: 73
Joined: Wed Sep 16, 2015 12:20 pm

Access denied for user 'www-data'@'localhost'

Post by marcolino7 »

Hi all,
I installed zomeminder 1.36 on Debian 11 Bullseye, following this guide for Buster using Bullseye repository:

https://zoneminder.readthedocs.io/en/la ... ebian.html

Then i run db configuration as follow:
https://wiki.zoneminder.com/MySQL

When i Start zoneminder I got this error:

Code: Select all

zoneminder.service - ZoneMinder CCTV recording and surveillance system
     Loaded: loaded (/lib/systemd/system/zoneminder.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-09-21 11:33:02 CEST; 2s ago
       Docs: http://zoneminder.readthedocs.org/en/latest/
    Process: 31241 ExecStart=/usr/bin/zmpkg.pl start (code=exited, status=255/EXCEPTION)
        CPU: 67ms

Sep 21 11:33:02 zoneminder zmpkg[31241]: ERR [Error reconnecting to db: errstr:Access denied for user 'www-data'@'localhost' (using password: NO) error val:]
Sep 21 11:33:02 zoneminder zmpkg.pl[31241]: Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/ZoneMinder/Config.pm line 96.
Sep 21 11:33:02 zoneminder zmpkg.pl[31241]: BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 147.
Sep 21 11:33:02 zoneminder zmpkg.pl[31241]: Compilation failed in require at /usr/share/perl5/ZoneMinder.pm line 33.
Sep 21 11:33:02 zoneminder zmpkg.pl[31241]: BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder.pm line 33.
Sep 21 11:33:02 zoneminder zmpkg.pl[31241]: Compilation failed in require at /usr/bin/zmpkg.pl line 34.
Sep 21 11:33:02 zoneminder zmpkg.pl[31241]: BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 34.
Sep 21 11:33:02 zoneminder systemd[1]: zoneminder.service: Control process exited, code=exited, status=255/EXCEPTION
Sep 21 11:33:02 zoneminder systemd[1]: zoneminder.service: Failed with result 'exit-code'.
Sep 21 11:33:02 zoneminder systemd[1]: Failed to start ZoneMinder CCTV recording and surveillance system.
Looking around I do not found a solution or something useful to fix.
Any help would be appreciated

Marco
Production Zoneminder 1.31.4 Ubuntu 16.04 LTS on VmWare ESXi
6 Cameras FOSCAM FI8918W
OpenHab Integration
bbunge
Posts: 2930
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Access denied for user 'www-data'@'localhost'

Post by bbunge »

Better instructions: https://wiki.zoneminder.com/Debian_11_B ... der_1.36.x
The readthedocs instructions are usually behind the times.

Last I checked there were no ZM 1.36.x installs for Bullseye. Also the version of MySQL likely has some security features that get turned on by default that block the install. Mariadb is a better choice for a database.
User avatar
kitkat
Posts: 193
Joined: Sun Jan 27, 2019 5:17 pm

Re: Access denied for user 'www-data'@'localhost'

Post by kitkat »

Are you sure the database user/pass are correct?

I'm on CentOS here so thing may well be different but the default database user is 'zmuser' rather than 'apache' (the CentOS version of www-data).

I'd investigate the MySQL users and grants, and create a file /etc/zm/conf.d/db-user.conf with the following content:

Code: Select all

ZM_DB_USER = (your-zm-db-user)
ZM_DB_PASS = (your-db-password)
You'd obviously be substituting the actual values instead of "(your-zm-user)" and "(your-db-password)"

Perhaps even delete the database and user and recreate them?

If you aren't conversant with or don't like the MySQL CLI (and who does?), try phpMyAdmin
habitats-tech
Posts: 1
Joined: Fri Nov 25, 2022 5:47 am

Re: Access denied for user 'www-data'@'localhost'

Post by habitats-tech »

For anyone looking at this thread trying to fix this error read-on.

If you have followed this guide https://wiki.zoneminder.com/Debian_11_B ... der_1.36.x there is a command missing from the shell script, which applies www-data access rights to zm.conf. Assuming you installed zoneminder under root this error will always come up.

To fix either manually enter the following command into the script or manually invoke it after the script has been run.

chgrp -c www-data /etc/zm/zm.conf
Post Reply