The automatic DB upgrade bit in the zm init script fails

Support and queries relating to all previous versions of ZoneMinder
Locked
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

The automatic DB upgrade bit in the zm init script fails

Post by lazyleopard »

I've been trying to get that automatic DB upgrade bit in scripts/zm.in to work. I've hit two main problems:

First, the code that attempts to extract the current version from the database was getting the wrong impression. My database is at version 1.22.0 but ZM_DYN_DB_VERSION said 1.21.4. I fixed that by going into mysql thus:

Code: Select all

# mysql -u webcam -p zm
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 49 to server version: 4.1.20-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> update Config set Value='1.22.0' where Name='ZM_DYN_DB_VERSION';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> quit
Bye
Second, zmupdate tries to do the mysql changes using the webcam mysql ID, and it just plain doesn't have the authority...

Code: Select all

Upgrade ZoneMinder database: 
Update agent starting at 06/07/05 22:53:36

Initiating database upgrade to version 1.22.2

Upgrading database to version 1.22.2
ERROR 1044 (42000) at line 8: Access denied for user 'webcam'@'localhost' to database 'zm'
Output: 
Command 'mysql -hlocalhost -uwebcam -pwatcher zm < /etc/zm/db/zm_update-1.22.0.sql' exited with status: 1
So, what authority would the user need to have in order to be able to do these updates?
Or should zmupdate use root instead?
Rick Hewett
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

That's odd as zmupdate.pl doesn't use DYN_DB_VERSION for any real purpose as far as I recall. The db version you are upgrading from is just supplied on the command line.

As the README indicates
zmupdate.pl –version=<from version> [--user=<database user> --pass=<database password>]

where ‘from version’ relates to the version of ZM you are upgrading from, 1.21.1 for example, and not the version you are upgrading to. All updates from that version onwards will be applied; however zmupdate.pl will only work with upgrades from 1.19.0 onwards. The ‘user’ and ‘pass’ options allow you to specify a database user and password with sufficient privilege to ‘alter’ the structure of the database. This is not necessarily the database user you use for ZoneMinder.
The user you will need to use will depend on your system is set up. Sometimes running as root means you don't have to supply a user, sometimes you need to supply a user (e.g. root) but no password and sometimes it's a whole different username and password.
Phil
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

The ZM_DYN_DB_VERSION reference comes from the code in the init script (from scripts/zm.in) that's trying to figure out whether to create or update the database automatically.

I think the best thing to do is to take all that stuff out of the init script. It really needs to be in a run-once-only post-install script instead.
Rick Hewett
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Ah, I see what you are looking at now. I think this is all stuff that Corey put in to allow for upgrades of the rpm. Hopefully he'll look in on this thread and comment.
Phil
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

This portion of the script was originally created for the rpm. zmupdate populates this field after it updates the database after version 1.22.0 I believe it was so any updates previous to that had not. Thus you have to update manually using zmupdate.pl as per the readme. afterward the script should work.

I have been meaning to separate this out to it's own script and have it called only if it exists, I'll do it this week and get the patches/files to Phil.
I'd really like to make it in Perl but I'm not as of yet that comfortable with Perl.

Regards,
Corey
Locked