Page 1 of 1
[SOLVED] Changing database location
Posted: Thu Oct 22, 2020 9:28 pm
by whoop
I am trying to change the default location of the mysql data directory.
I think I did everything correctly and when I run:
in a mysql session I get the new data location.
However when I try to start zoneminder I get the following error for zmpkg.pl in the logs (and zoneminder fails to start):
Code: Select all
ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) error val:]
The /var/lib/mysql/mysql.sock is still the old location and I don't know where zmpkg.pl (or zoneminder) is getting this location from.
Re: Changing database location
Posted: Fri Oct 23, 2020 3:43 pm
by Magic919
One is the data directory, the other (which errors) is the socket for MySQL to connect to. Two different things.
Re: Changing database location
Posted: Fri Oct 23, 2020 4:17 pm
by whoop
Valid point.
However I was under the impression that moving the entire directory and than editing /etc/my.cnf.d/mariadb-server.cnf:
Code: Select all
[mysqld]
datadir=/new/mysql
socket=/new/mysql/mysql.sock
would also solve the socket problem..
The mysqld service seems to be running fine (select @@datadir; gives me the proper new location).
httpd service seems to be running fine.
Only zoneminder service still fails while pointing at the old socket location --> /var/lib/mysql/mysql.sock in the error.
journalctl -xe:
Code: Select all
-- Unit zoneminder.service has begun starting up.
Oct 23 16:08:21 testserver zmpkg.pl[4130]: DBI connect('database=zm;host=localhost','test',...) failed: Can't connect to local MySQL server through socket >
Oct 23 16:08:21 testserver zmpkg.pl[4130]: DBI connect('database=zm;host=localhost','test',...) failed: Can't connect to local MySQL server through socket >
Oct 23 16:08:21 testserver zmpkg[4130]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' >
Oct 23 16:08:21 testserver zmpkg.pl[4130]: DBI connect('database=zm;host=localhost','test',...) failed: Can't connect to local MySQL server through socket >
Oct 23 16:08:21 testserver zmpkg[4130]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' >
Oct 23 16:08:21 testserver zmpkg.pl[4130]: Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line>
Oct 23 16:08:21 testserver zmpkg.pl[4130]: BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line 147.
Oct 23 16:08:21 testserver zmpkg.pl[4130]: Compilation failed in require at /usr/share/perl5/vendor_perl/ZoneMinder.pm line 33.
Oct 23 16:08:21 testserver zmpkg.pl[4130]: BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/ZoneMinder.pm line 33.
Oct 23 16:08:21 testserver zmpkg.pl[4130]: Compilation failed in require at /usr/bin/zmpkg.pl line 34.
Oct 23 16:08:21 testserver zmpkg.pl[4130]: BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 34.
Oct 23 16:08:21 testserver systemd[1]: zoneminder.service: Control process exited, code=exited status=255
Oct 23 16:08:21 testserver systemd[1]: zoneminder.service: Failed with result 'exit-code'.
Oct 23 16:08:21 testserver systemd[1]: Failed to start ZoneMinder CCTV recording and security system.
-- Subject: Unit zoneminder.service has failed
Re: Changing database location
Posted: Fri Oct 23, 2020 6:32 pm
by Magic919
You could try stating it explicitly in the Zoneminder config file. I’d have thought it would pick it up from my.cnf, just based on Linux experience.
Re: Changing database location
Posted: Fri Oct 23, 2020 8:45 pm
by whoop
Well it wasn't really straightforward figuring that out(at least not for me). But your suggestion seems to have helped me allot. Thank you.
I added a file named 03-custom.conf to /etc/zm/conf.d/
and added the following:
Code: Select all
ZM_DB_HOST=localhost:/new/mysql/mysql.sock
I think this is the proper way to do it.
Now Zoneminder will start. Have not checked if everything is working though.
Thanks again.
Re: [SOLVED] Changing database location
Posted: Sat Oct 24, 2020 6:12 am
by Magic919
I’m glad it helped.
Yes, popping that in the custom config file is best practice. It means it doesn’t get clobbered during upgrades later on.