Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Users

running mythconverg_backup.pl as non-mythtv user

 

 

MythTV users RSS feed   Index | Next | Previous | View Threaded


rjmorris at nc

Aug 19, 2012, 9:11 AM

Post #1 of 6 (457 views)
Permalink
running mythconverg_backup.pl as non-mythtv user

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.

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?
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


mtdean at thirdcontact

Aug 19, 2012, 5:33 PM

Post #2 of 6 (405 views)
Permalink
Re: running mythconverg_backup.pl as non-mythtv user [In reply to]

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
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


rjmorris at nc

Aug 19, 2012, 7:34 PM

Post #3 of 6 (400 views)
Permalink
Re: running mythconverg_backup.pl as non-mythtv user [In reply to]

"Michael T. Dean" <mtdean [at] thirdcontact> wrote on Sun, Aug 19, 2012 at 08:33:22PM -0400:
> On 08/19/2012 12:11 PM, Joey Morris wrote:
> >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.

Thanks for the explanation and suggestions, Mike. This all makes
sense. I'm not exactly sure which direction I'm going to go, but I
think running it as my mythtv user (who doesn't have the password in
~/.my.cnf) will be the most straightforward approach.
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


mikep at randomtraveller

Aug 20, 2012, 1:51 AM

Post #4 of 6 (401 views)
Permalink
Re: running mythconverg_backup.pl as non-mythtv user [In reply to]

On 19/08/12 17:11, 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
>
Confusion here? The 'database user' mysql requires credentials for has *nothing*
to do with the 'login user' who runs the script.

It is perfectly acceptable to run the myth programs from any login providing
valid credentials for the mythtv database user are supplied in the appropriate
mysql.txt/config.xml files.

(Assuming that the logged in user has the correct permissions to access the
required directories and files, of course.)

--

Mike Perkins

_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


rjmorris at nc

Aug 20, 2012, 4:58 AM

Post #5 of 6 (393 views)
Permalink
Re: running mythconverg_backup.pl as non-mythtv user [In reply to]

Mike Perkins <mikep [at] randomtraveller> wrote on Mon, Aug 20, 2012 at 09:51:15AM +0100:
> On 19/08/12 17:11, 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
> >
> Confusion here? The 'database user' mysql requires credentials for
> has *nothing* to do with the 'login user' who runs the script.

There is a connection, actually. mysqldump looks for MySQL options in
the following files, with options found in later files taking
precedence:

/etc/my.cnf
/etc/mysql/my.cnf
$SYSCONFDIR/my.cnf
$MYSQL_HOME/my.cnf
value of --defaults-extra-file command line option
~/.my.cnf

[http://dev.mysql.com/doc/refman/5.5/en/option-files.html]

mythconverg_backup.pl takes the password out of ~/.mythtv/config.xml
and passes it to mysqldump via the --defaults-extra-file option.
However, if the login user has a password in ~/.my.cnf, mysqldump uses
that password instead. That's what was happening in my case, so
mysqldump tried to log in as the database user but with the login
user's password.
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


mikep at randomtraveller

Aug 20, 2012, 1:04 PM

Post #6 of 6 (385 views)
Permalink
Re: running mythconverg_backup.pl as non-mythtv user [In reply to]

On 20/08/12 12:58, Joey Morris wrote:
> Mike Perkins <mikep [at] randomtraveller> wrote on Mon, Aug 20, 2012 at 09:51:15AM +0100:
>> On 19/08/12 17:11, 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
>>>
>> Confusion here? The 'database user' mysql requires credentials for
>> has *nothing* to do with the 'login user' who runs the script.
>
> There is a connection, actually. mysqldump looks for MySQL options in
> the following files, with options found in later files taking
> precedence:
>
> /etc/my.cnf
> /etc/mysql/my.cnf
> $SYSCONFDIR/my.cnf
> $MYSQL_HOME/my.cnf
> value of --defaults-extra-file command line option
> ~/.my.cnf
>
> [http://dev.mysql.com/doc/refman/5.5/en/option-files.html]
>
> mythconverg_backup.pl takes the password out of ~/.mythtv/config.xml
> and passes it to mysqldump via the --defaults-extra-file option.
> However, if the login user has a password in ~/.my.cnf, mysqldump uses
> that password instead. That's what was happening in my case, so
> mysqldump tried to log in as the database user but with the login
> user's password.
>
Yes, but that is to do with the content of the /login user's files/, not the
value of the login user's name. Your system username can be anything, the
database credentials anything else. The two are *not* connected, even in the
slightest.

What you choose to store as text in files under any user is your affair.

--

Mike Perkins

_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users

MythTV users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.