Mysql error in log "Unknown MySQL Server Host"
Mysql error in log "Unknown MySQL Server Host"
Hi, I get the following error in the log file when I start ZM v1.20.1
Why is it not displaying the wrong values ? 'ZM_DB_SERVER'=localhost ?
==> zmdc.log <==
Starting pending process, zmtrigger.pl
'zmtrigger.pl' started at 05/03/12 11:32:09
'zmtrigger.pl' starting at 05/03/12 11:32:09, pid = 9197
DBI connect('database=ZM_DB_NAME;host=ZM_DB_SERVER','ZM_DB_USERA',...) failed: Unknown MySQL Server Host 'ZM_DB_SERVER' (1) at /usr/local/bin/zmtrigger.pl line 62
Can't call method "prepare_cached" on an undefined value at /usr/local/bin/zmtrigger.pl line 64.
BEGIN failed--compilation aborted at /usr/local/bin/zmtrigger.pl line 72.
'zmtrigger.pl ' crashed at 05/03/12 11:32:09, exit status 255
# cat /usr/local/etc/zm.conf
# ZoneMinder config
ZM_DB_SERVER=localhost
ZM_DB_NAME=zm
ZM_DB_USER=zm
ZM_DB_PASS=zmadmin
Why is it not displaying the wrong values ? 'ZM_DB_SERVER'=localhost ?
==> zmdc.log <==
Starting pending process, zmtrigger.pl
'zmtrigger.pl' started at 05/03/12 11:32:09
'zmtrigger.pl' starting at 05/03/12 11:32:09, pid = 9197
DBI connect('database=ZM_DB_NAME;host=ZM_DB_SERVER','ZM_DB_USERA',...) failed: Unknown MySQL Server Host 'ZM_DB_SERVER' (1) at /usr/local/bin/zmtrigger.pl line 62
Can't call method "prepare_cached" on an undefined value at /usr/local/bin/zmtrigger.pl line 64.
BEGIN failed--compilation aborted at /usr/local/bin/zmtrigger.pl line 72.
'zmtrigger.pl ' crashed at 05/03/12 11:32:09, exit status 255
# cat /usr/local/etc/zm.conf
# ZoneMinder config
ZM_DB_SERVER=localhost
ZM_DB_NAME=zm
ZM_DB_USER=zm
ZM_DB_PASS=zmadmin
more info - mysql
I enabled logging in mysql to the mysql.log file, and although i still see the error above form zmtrigger.pl
In the sql log everything seems fine.
Here is a snippit.
050312 14:00:50 48 Connect zm@localhost on zm
48 Query select * from Config
48 Quit
21 Query select count(Id) as ZoneCount from Zones where MonitorId = '7'
21 Query select count(if(Archived=0,1,NULL)) as EventCount, count(if(Archived,1,NULL)) as ArchEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 1 HOUR && Archived = 0,1,NULL)) as HourEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 1 DAY && Archived = 0,1,NULL)) as DayEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 7 DAY && Archived = 0,1,NULL)) as WeekEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 1 MONTH && Archived = 0,1,NULL)) as MonthEventCount from Events as E where MonitorId = '7'
050312 14:00:52 35 Query select * from Filters where (AutoArchive = 1 or AutoDelete = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1 or AutoExecute != '') order by Name
35 Query select * from Filters where (AutoArchive = 1 or AutoDelete = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1 or AutoExecute != '') order by Name
050312 14:01:18 49 Connect zm@localhost on zm
49 Query select * from Monitors
050312 14:01:28 49 Query select * from Monitors
050312 14:01:38 49 Query select * from Monitors
50 Connect zm@localhost on zm
50 Query select * from Config
50 Quit
51 Connect zm@localhost on
51 Init DB zm
51 Query select Name, Value, Type from Config order by Id
51 Query select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = 7
050312 14:01:39 51 Query select Id,Name,Type+0,Units,LoX,LoY,HiX,HiY,AlarmRGB,CheckMethod+0,MinPixelThreshold,MaxPixelThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs from Zones where MonitorId = 7 order by Type, Id
050312 14:01:49 49 Query select * from Monitors
050312 14:01:59 49 Query select * from Monitors
050312 14:02:09 49 Query select * from Monitors
050312 14:02:19 49 Query select * from Monitors
050312 14:02:29 49 Query select * from Monitors
050312 14:02:39 49 Query select * from Monitors
050312 14:02:49 49 Query select * from Monitors
52 Connect zm@localhost on zm
52 Query select * from Config
52 Quit
53 Connect zm@localhost on
53 Init DB zm
53 Query select Name, Value, Type from Config order by Id
53 Query select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = 7
53 Query select Id,Name,Type+0,Units,LoX,LoY,HiX,HiY,AlarmRGB,CheckMethod+0,MinPixelThreshold,MaxPixelThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs from Zones where MonitorId = 7 order by Type, Id
050312 14:02:59 49 Query select * from Monitors
050312 14:03:09 49 Query select * from Monitors
050312 14:03:19 49 Query select * from Monitors
050312 14:03:29 49 Query select * from Monitors
050312 14:03:39 49 Query select * from Monitors
050312 14:03:49 49 Query select * from Monitors
050312 14:03:59 49 Query select * from Monitors
050312 14:04:09 49 Query select * from Monitors
050312 14:04:19 49 Query select * from Monitors
In the sql log everything seems fine.
Here is a snippit.
050312 14:00:50 48 Connect zm@localhost on zm
48 Query select * from Config
48 Quit
21 Query select count(Id) as ZoneCount from Zones where MonitorId = '7'
21 Query select count(if(Archived=0,1,NULL)) as EventCount, count(if(Archived,1,NULL)) as ArchEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 1 HOUR && Archived = 0,1,NULL)) as HourEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 1 DAY && Archived = 0,1,NULL)) as DayEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 7 DAY && Archived = 0,1,NULL)) as WeekEventCount, count(if(StartTime>'2005-03-12 14:00:49' - INTERVAL 1 MONTH && Archived = 0,1,NULL)) as MonthEventCount from Events as E where MonitorId = '7'
050312 14:00:52 35 Query select * from Filters where (AutoArchive = 1 or AutoDelete = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1 or AutoExecute != '') order by Name
35 Query select * from Filters where (AutoArchive = 1 or AutoDelete = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1 or AutoExecute != '') order by Name
050312 14:01:18 49 Connect zm@localhost on zm
49 Query select * from Monitors
050312 14:01:28 49 Query select * from Monitors
050312 14:01:38 49 Query select * from Monitors
50 Connect zm@localhost on zm
50 Query select * from Config
50 Quit
51 Connect zm@localhost on
51 Init DB zm
51 Query select Name, Value, Type from Config order by Id
51 Query select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = 7
050312 14:01:39 51 Query select Id,Name,Type+0,Units,LoX,LoY,HiX,HiY,AlarmRGB,CheckMethod+0,MinPixelThreshold,MaxPixelThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs from Zones where MonitorId = 7 order by Type, Id
050312 14:01:49 49 Query select * from Monitors
050312 14:01:59 49 Query select * from Monitors
050312 14:02:09 49 Query select * from Monitors
050312 14:02:19 49 Query select * from Monitors
050312 14:02:29 49 Query select * from Monitors
050312 14:02:39 49 Query select * from Monitors
050312 14:02:49 49 Query select * from Monitors
52 Connect zm@localhost on zm
52 Query select * from Config
52 Quit
53 Connect zm@localhost on
53 Init DB zm
53 Query select Name, Value, Type from Config order by Id
53 Query select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = 7
53 Query select Id,Name,Type+0,Units,LoX,LoY,HiX,HiY,AlarmRGB,CheckMethod+0,MinPixelThreshold,MaxPixelThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs from Zones where MonitorId = 7 order by Type, Id
050312 14:02:59 49 Query select * from Monitors
050312 14:03:09 49 Query select * from Monitors
050312 14:03:19 49 Query select * from Monitors
050312 14:03:29 49 Query select * from Monitors
050312 14:03:39 49 Query select * from Monitors
050312 14:03:49 49 Query select * from Monitors
050312 14:03:59 49 Query select * from Monitors
050312 14:04:09 49 Query select * from Monitors
050312 14:04:19 49 Query select * from Monitors
Line 62 from /usr/local/bin/zmtrigger.pl
Line 62 from /usr/local/bin/zmtrigger.pl
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
#I proceeded to replace line 62 with
my $dbh = DBI->connect( "DBI:mysql:database=zm;host=localhost", "zm", "zmadmin");
#producing new error in log
Bareword "ZM_DB_USERA" not allowed while "strict subs" in use at /usr/local/bin/zmtrigger.pl line 123.
Bareword "ZM_DB_PASSA" not allowed while "strict subs" in use at /usr/local/bin/zmtrigger.pl line 123.
#line 123
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
#Why is it using ZM_DB_USERA and not ZM_DB_USER ?
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
#I proceeded to replace line 62 with
my $dbh = DBI->connect( "DBI:mysql:database=zm;host=localhost", "zm", "zmadmin");
#producing new error in log
Bareword "ZM_DB_USERA" not allowed while "strict subs" in use at /usr/local/bin/zmtrigger.pl line 123.
Bareword "ZM_DB_PASSA" not allowed while "strict subs" in use at /usr/local/bin/zmtrigger.pl line 123.
#line 123
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
#Why is it using ZM_DB_USERA and not ZM_DB_USER ?
Fix for zmtrigger.pl
In zmtrgger.pl, (ZM 1.20.1)
replaced
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
with
my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS );
from zmfilter.pl in 2 places.
Now there is no more errors in log file.
replaced
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
with
my $dbh = DBI->connect( "DBI:mysql:database=".&ZM_DB_NAME.";host=".&ZM_DB_SERVER, &ZM_DB_USER, &ZM_DB_PASS );
from zmfilter.pl in 2 places.
Now there is no more errors in log file.
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
- lazyleopard
- Posts: 403
- Joined: Tue Mar 02, 2004 6:12 pm
- Location: Gloucestershire, UK
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
No. The problem was with ZM_DB_USERA and ZM_DB_PASSA rather than ZM_DB_USER and ZM_DB_PASS (without any 'A's). The & I think is just a way of getting perl not to complain about references and whilst it won't hurt should not be necessary if the constants are correctly defined. This was just in zmtrigger.pl btw.
Phil
Phil
I made a new RPM that has this correction in it. The source RPM is there as well.
ftp://download.computerntelecom.com/pub ... updates/3/
Cheers,
Cordel
ftp://download.computerntelecom.com/pub ... updates/3/
Cheers,
Cordel
- lazyleopard
- Posts: 403
- Joined: Tue Mar 02, 2004 6:12 pm
- Location: Gloucestershire, UK
Hmmm... The '&'s do seem to be needed within the BEGIN block. If they're not there the script gets a bit confused:zoneminder wrote:The & I think is just a way of getting perl not to complain about references and whilst it won't hurt should not be necessary if the constants are correctly defined.
Code: Select all
'zmtrigger.pl' started at 05/03/21 22:08:01
'zmtrigger.pl' starting at 05/03/21 22:08:01, pid = 8807
DBI connect('database=ZM_DB_NAME;host=ZM_DB_SERVER','ZM_DB_USER',...) failed: Unknown MySQL Server Host 'ZM_DB_SERVER' (1) at /usr/bin/zmtrigger.pl line 62
Can't call method "prepare_cached" on an undefined value at /usr/bin/zmtrigger.pl line 64.
BEGIN failed--compilation aborted at /usr/bin/zmtrigger.pl line 72.
'zmtrigger.pl ' crashed at 05/03/21 22:08:02, exit status 255
Rick Hewett
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
- lazyleopard
- Posts: 403
- Joined: Tue Mar 02, 2004 6:12 pm
- Location: Gloucestershire, UK
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact: