Page 1 of 1
Resetting Event Number??
Posted: Sun May 10, 2009 9:33 pm
by Verbatim
Hello,
How would I reset the event count back down to 0? Or any number for that matter?
Thanks,
Alison
Posted: Tue May 12, 2009 8:39 am
by foreverg
delete all the events thel empty the mysql Events table

Resetting Event Number??
Posted: Thu Jun 11, 2009 3:38 am
by zappbrannigan
I too am interested in doing this.
When you say "delete all events", I would do this through the web interface, correct?
Could you elaborate on clearing the mysql events table? (I have zero experience w/ mysql).
Also, even if you do these things you're still left with the images right? Can I simply rm these images w/o causing any problems?
thanks,
eric
Re: Resetting Event Number??
Posted: Thu Jun 11, 2009 4:23 am
by cordel
zappbrannigan wrote:I too am interested in doing this.
When you say "delete all events", I would do this through the web interface, correct?
Could you elaborate on clearing the mysql events table? (I have zero experience w/ mysql).
Also, even if you do these things you're still left with the images right? Can I simply rm these images w/o causing any problems?
thanks,
eric
No you lose all the events by dumping the table.
The event ID's are tracked by the database using the auto increment setting. If there is ever a duplicate the SQL DB would fall flat on its face. So there is no way to retain data and reset the count.
Re: Resetting Event Number??
Posted: Thu Jun 11, 2009 5:31 am
by zappbrannigan
If the images are deleted, that's okay.
The question still stands, how do I zero the event count?
TIA,
eric
Posted: Thu Jun 11, 2009 6:14 am
by cordel
Drop and recreate the events table.
Assuming your db is named ZM:
The necessary disclaimer:
You are about to remove and forever lose your events. This may or may not work for you. No one can be held accountable should you follow these instructions. It is up to you to determine how your system is configured and the appropriate syntax to accommodate that configuration.
With that being said, this should work unless you have done something weird and also assumes you have named the database "zm";
Code: Select all
# /etc/init.d/zoneminder stop
# mysqldump -d zm Events > events_table.sql
# mysql zm
mysql> DROP TABLE Events;
mysql> exit
# mysql zm < events_table.sql
# /etc/init.d/zoneminder start
There are a few assumptions made but this is the basics of it. It might vary a bit according to your distro but not by much.
Re: Resetting Event Number??
Posted: Thu Jun 11, 2009 10:53 pm
by zappbrannigan
Well, nothing seems to have been broken, however...
It did purge all the image files which I did expect but the ID number wasn't reset. (If you're in "record" mode and you open a watch window there's a list of events each with an ID number. I was hoping to reset that number but no such luck.)
Any ideas?
TIA,
eric
BTW, for my or anyone else's future reference, the idea of the previous code snippet is: make a backup of zm's Events table, but without the table's data. Then from within mysql, delete the Events table, then restore the previously backed up, now empty, table.
Posted: Mon Jun 15, 2009 2:39 am
by cordel
Okay wasn't sure if the auto numbering would carry over, seems that it does so you will need to add an instruction before exiting mysql and starting ZM:
Code: Select all
ALTER TABLE Events AUTO_INCREMENT = 1;
Alternatively, you can also use truncate table as it will reset the auto increment number as well.
http://dev.mysql.com/doc/refman/5.0/en/truncate.html
Posted: Wed Jun 17, 2009 3:52 am
by zappbrannigan
Well, that seems to have done it. Thanks.
Just to tie everything up nice and neat:
Code: Select all
# /etc/init.d/zoneminder stop
# mysql zm
mysql> TRUNCATE TABLE Events;
mysql> exit
# /etc/init.d/zoneminder start
It looks like the mysqldump and the restoring of the dump file are
not necessary. Is that correct?
Thanks again,
eric
Posted: Tue Jul 07, 2009 2:15 am
by cordel
You would still likely need to dump the events. Mysql I believe will pick up from the highest ID in the table, if it does not, then you risk it creating a conflict that would bring down the table and the server.
If you have the inclination to test it out, by all means please do as I would be interested myself.
Posted: Mon May 31, 2010 2:48 pm
by psyhomb
zappbrannigan wrote:
Well, that seems to have done it. Thanks.
Just to tie everything up nice and neat:
Code: Select all
# /etc/init.d/zoneminder stop
# mysql zm
mysql> TRUNCATE TABLE Events;
mysql> exit
# /etc/init.d/zoneminder start
It looks like the mysqldump and the restoring of the dump file are
not necessary. Is that correct?
Thanks again,
eric
Is this working without any negative consequences?
Posted: Sun Jun 06, 2010 4:26 pm
by zappbrannigan
psyhomb wrote:zappbrannigan wrote:
Well, that seems to have done it. Thanks.
Just to tie everything up nice and neat:
Code: Select all
# /etc/init.d/zoneminder stop
# mysql zm
mysql> TRUNCATE TABLE Events;
mysql> exit
# /etc/init.d/zoneminder start
It looks like the mysqldump and the restoring of the dump file are
not necessary. Is that correct?
Thanks again,
eric
Is this working without any negative consequences?
I just tried it, seems to have worked fine.
I second that
Posted: Wed Jan 05, 2011 4:03 pm
by Jason_Bassett
Seems to be working fine on my test systems too. Will soon invoke it on my live ones.
J
Posted: Wed Jan 05, 2011 7:50 pm
by PacoLM
Good trick!
possible Daily Honor Points...i mean....clean up script....
Posted: Tue Feb 15, 2011 2:46 am
by masam
so, what if we put the code into a shell script and run it as a crontab job, say, at midnight?!?!
(begin code)
!#/bin/bash/
echo "TRUNCATE TABLE Events;" > /home/USERNAME/zmsql.sql
/etc/init.d/zoneminder stop
mysql -uROOT -pPASSWORD use zm << zmsql.sql
/etc/init.d/zoneminder start
(end code)
then set up a crontab that uses this?
hope this helps....