<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 7, 2024 at 10:02 PM Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz">stephen_agent@jsw.gen.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 7 Aug 2024 12:13:35 -0400, you wrote:<br>
<br><br>
<br>
Access to a MariaDB or MySQL database normally requires a username and<br>
a password.<br>
<br>
The <a href="http://mythconverg_backup.pl" rel="noreferrer" target="_blank">mythconverg_backup.pl</a> script will read a configuration file to get<br>
the database password. So it is likely that you have one of them in<br>
the default place it looks for it. The default name is "backuprc",<br>
and it should be in the $(HOME)/.mythtv directory. The script passes<br>
the username and password to mysqldump when it uses that command.<br>
<br>
The <a href="http://optimise_mythdb.pl" rel="noreferrer" target="_blank">optimise_mythdb.pl</a> script uses the MythTV Perl bindings to do<br>
commands on the mythconverg database. The bindings automatically<br>
retrieve the database information including the username and password<br>
from your config.xml file, and pass that information on when accessing<br>
the database.<br>
<br>
When you use mariadb-check directly, you have to do the same - provide<br>
the username and password to allow access to the mythconverg database.<br>
If you do not want to do that, you can instead run mariadb-check from<br>
root without giving it any username or password. If you do give it a<br>
username, you have to also supply a matching password.<br>
<br>
Note that running MariaDB or MySQL commands from root without a<br>
username/password only works locally on the box where the database is<br>
located. It uses a special case where a Unix socket is used to<br>
connect to MariaDB/MySQL and that is only accepted locally. It is<br>
there so that if you have lost your username/password, the system<br>
administrator can recover you from that situation. And also to allow<br>
initial creation of databases and setting up their usernames and<br>
passwords. This special root access can be turned off, if the admins<br>
are completely paranoid. In that case, losing your credentials can<br>
not be fixed and all access to the database will be lost.<br>
<br>
When you are running the mythtv-database-backup.sh script from<br>
systemd, it will be being run as root, and mariadb-check will not need<br>
a username and password to access the database. When you run it from<br>
any other user, mariadb-check will inherit the user from the user that<br>
runs the script and will then need a matching password to access the<br>
database.<br>
<br>
The simple way to fix your problem would be to just run the systemd<br>
unit. If you want to run mythtv-database-backup.sh from another user,<br>
just tell systemd to run the unit:<br>
<br>
sudo systemctl start <name of systemd unit><br>
__________<br></blockquote><div><br></div><div>Thanks for the information, Stephen. This test BE/FE combo is doing nothing remotely so a lot of the problems go away.</div><div><br></div><div>Currently, the mythtv-database-backup.sh is being run by a systemd timer/service routine, so root access.</div><div><br></div><div>This is why mariadb-check and <a href="http://optimize_mythdb.pl">optimize_mythdb.pl</a> are running correctly. I have no file called backuprc anywhere.</div><div>The script runs the <a href="http://mythconverg_backup.pl">mythconverg_backup.pl</a> in a way I don't understand. There are some variables that are assigned that seem to be important.</div><div><br></div><div>DBNAME="mythconverg"<br>USER=mythtv<br>BKUP_LOG=/tmp/backup-mythconverg.log<br>export MYTHCONFDIR=/home/$USER/.mythtv/<br></div><div><br></div><div>Either of these statements seem to get the job done. I've used the first forever, but I just tested the second and it also works.</div><div><br></div><div>sudo --preserve-env --user=$USER /usr/share/mythtv/<a href="http://mythconverg_backup.pl">mythconverg_backup.pl</a> --rotate=5 --verbose 2>&1 >> $BKUP_LOG<br><br></div><div>/usr/share/mythtv/<a href="http://mythconverg_backup.pl">mythconverg_backup.pl</a> --rotate=5 --verbose 2>&1 >> $BKUP_LOG<br></div><div><br></div><div>Since I don't understand the sudo --preserve-env --user= part I'm not sure I should be using it? </div><div><br></div><div>I may have stolen this from one of your scripts years ago, Stephen.</div><div><br></div><div>JIm A<br><br></div></div></div>