table 'zm.Config' doesn't exist in engine

Previous development branch now released as 1.36
Locked
User avatar
zd59
Posts: 102
Joined: Wed Jan 18, 2017 1:39 pm
Location: EU - Slovenia

table 'zm.Config' doesn't exist in engine

Post by zd59 »

Zoneminder version 1.35.5
mariadb-10.5.4

I have huge events database.
At some time there were sudden power drop (UPS battery failed) and this resulted in mysql database corruption.
Mysql failed to start with database corruption error.
So I assumed the failed database is in a mysql table and hoped, that zm database is not corrupted.
And so I deleted all files and folders related to mysql database in /var/lib/mysql except zm folder.

Then I recreated mysql database:

Code: Select all

mysql_install_db --user=mysql
Then I created zmuser in a database:

Code: Select all

use mysql;
grant select,insert,update,delete,create,alter,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass'; 

Code: Select all

MariaDB [zm]> show tables
    -> ;
+-----------------+
| Tables_in_zm    |
+-----------------+
| Config          |
| ControlPresets  |
| Controls        |
| Devices         |
| Events          |
| Events_Archived |
| Events_Day      |
| Events_Hour     |
| Events_Month    |
| Events_Week     |
| Filters         |
| Frames          |
| Groups          |
| Groups_Monitors |
| Logs            |
| Manufacturers   |
| Maps            |                                                                                                                                          
| Models          |                                                                                                                                          
| MonitorPresets  |                                                                                                                                          
| Monitor_Status  |                                                                                                                                          
| Monitors        |                                                                                                                                          
| MontageLayouts  |                                                                                                                                          
| Servers         |                                                                                                                                          
| States          |                                                                                                                                          
| Stats           |                                                                                                                                          
| Storage         |                                                                                                                                          
| TriggersX10     |                                                                                                                                          
| Users           |
| ZonePresets     |
| Zones           |
So there is a table zm.Config and the rights to operate on database is correct.
So what must I do to reuse preserved zm database in a newly created mysql database?
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: table 'zm.Config' doesn't exist in engine

Post by Magic919 »

Did you attempt repair of the DB or the table?

I’m no DB expert, but I’d copy over the DB you have to the fresh part of the FS and have a go at repairing.
-
User avatar
zd59
Posts: 102
Joined: Wed Jan 18, 2017 1:39 pm
Location: EU - Slovenia

Re: table 'zm.Config' doesn't exist in engine

Post by zd59 »

On my bad luck I did not checked backup and lost it. :(
I've preserved only folder /var/lib/mysql/zm and overwrote mysql database with fresh empty one.

Think of a situation, where you have to move your existing zm database (folder /var/lib/mysql/zm ) to other machine with fresh installed mariadb and no zoneminder database - you wish to move entire zoneminder with existing data to other machine and preserve database (camera settings, events..).
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: table 'zm.Config' doesn't exist in engine

Post by Magic919 »

Maybe that wasn’t clear.

I think you have a copy of the file system for the ZM DB. I’m suggesting you copy that to where it needs to live. Then have a go at repairing it.
-
User avatar
zd59
Posts: 102
Joined: Wed Jan 18, 2017 1:39 pm
Location: EU - Slovenia

Re: table 'zm.Config' doesn't exist in engine

Post by zd59 »

Problem solved: (slackware64-current)

State before and required intervention:
mysql daemon failed to start, reporting database corruption. :(
I assume failure in mysql database, and zoneminder database is without failure. At the end that proved as correct.

1. move zoneminder database /var/lib/mysql/zm away - to backup location. This is a large database with a lot of events recorded

2. mysql (mariadb) database freshly installed:

Code: Select all

mysql_install_db --user=mysql 
3. creating fresh empty zoneminder database:

Code: Select all

# mysql -u root -p
source /usr/share/zoneminder/db/zm_create.sql
use mysql;
grant select,insert,update,delete,create,alter,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';
quit;
4. stop mariadb server daemon

5. remove created zoneminder database in point 3 above:

Code: Select all

rm -r /var/lib/mysql/zm
6. copy zoneminder database from backup (point 1.) back to /var/lib/mysql/

7. start mysql server daemon - successfully

On that point I've successfully started zoneminder and found all events ever recorded. :D
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: table 'zm.Config' doesn't exist in engine

Post by Magic919 »

Good news. Glad it worked out.
-
Locked