[mythtv-users] running mythconverg_backup.pl as non-mythtv user

Michael T. Dean mtdean at thirdcontact.com
Mon Aug 20 00:33:22 UTC 2012


On 08/19/2012 12:11 PM, Joey Morris wrote:
> I tried to run mythconverg_backup.pl on a 0.24 database as a user
> other than my mythtv user. I also run mythfrontend as that user, so
> the user has the appropriate mythconverg username/password defined in
> the files under the ~/.mythtv directory. When I ran the backup script,
> it failed with the message:
>
>    mysqldump: Got error: 1045: Access denied for user
>    'mythtv'@'localhost' (using password: YES) when trying to connect
>
> It looks like the backup script is picking up the database password
> from ~/.my.cnf instead of from the files in ~/.mythtv. The script does
> output this:
>
>    Attempting to use supplied password for mysqldump.
>    Any [client] or [mysqldump] password specified in the MySQL options
>    file will take precedence.
>
> So maybe I should have expected ~/.my.cnf to override the supplied
> password. When I saw that message, though, I think I misunderstood
> which password it considered the "supplied password" and/or which file
> it meant by the "MySQL options file". I assumed the supplied password
> was the one in ~/.mythtv/config.xml and the MySQL options file was
> ~/.mythtv/mysql.txt.

The MySQL options files are the files MySQL applications use to specify 
MySQL options--on *nix, that would be:

/etc/my.cnf
/etc/mysql/my.cnf
$SYSCONFDIR/my.cnf
$MYSQL_HOME/my.cnf
or
~/.my.cnf

and on Windows it would be
%WINDIR%\my.ini or $WINDIR%\my.cnf
C:\my.ini or C:\my.cnf
or
%INSTALLDIR%\my.ini or %INSTALLDIR%\my.cnf

That's why I called it "MySQL options file"--the name MySQL uses for 
it--versus specifying a specific file name/location and confusing people 
who don't know that there's not just one (not to mention the various 
names--with and without initial period or using ini instead of cnf).

> I was able to work around this problem in two different ways:
>
> 1) I edited the script to change the mysqldump option
>     --defaults-extra-file to --defaults-file.
>
> 2) I renamed the user's .my.cnf file (after changing the script back
>     to --defaults-extra-file).
>
> Is it recommended to run the backup script as the mythtv user? If I do
> run it as a non-mythtv user, is there a better way to make it work
> than the workarounds I used?

It can be run as any system user, as long as a valid 
$HOME/.mythtv/config.xml is provided.  Generally, the idea is that you 
wouldn't have a username/password specified in your MySQL options file.

I'm using --defaults-extra-file so that a) we don't pass 
username/password on the command line, and b) users can specify other 
options in MySQL options file (or, more likely, pick up the appropriate 
ones from their system install).  Using --defaults-file, it will use 
only the specified file to pick up all configuration (which could break 
mysqldump on many systems).

If you really want/need the password in your MySQL options file, the 
approaches I can think of are to a) change the backup script, b) change 
your MySQL options file (i.e. have a script rename the with-password 
options file, then put a without-password options file in place, run the 
backup, then put the options file back how it should be for other 
stuff), or c) use a different user that can be configured without the 
password in the options file.

Mike


More information about the mythtv-users mailing list