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

Mailing List Archive: MythTV: Users

What to do when you can't remember the password for mysql

 

 

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


cummings at kjchome

Apr 19, 2007, 10:58 PM

Post #1 of 9 (8311 views)
Permalink
What to do when you can't remember the password for mysql

OK, a while ago, I setup MythTV on my home server (with a PVR-350 card)
on FC5 before Jarod had updated his instructions for FC5. I muddled
through the installation, using a combination of the FC4 and FC3
instructions, and using RPMS from ATRPMS, I got MySQL, ivtv, and mythtv
all installed an running. Woo Hoo!

I was able to add a new PC5500-HD card to my setup this past Christmas
without any problem. Great! Cool!

Now, I want to add a remote frontend. This requires a change to the
MySQL setup. I have to issue a GRANT command like so:

> $ mysql -u root mythconverg
> mysql> grant all on mythconverg.* to mythtv@"%" identified by "mythtv";
> mysql> flush privileges;

My problem? When I try and login to mysql I can't remember the password
I used for root! I am able to login as mythtv, but trying to issue the
"grant all" command gives me:

ERROR 1044 (42000): Access denied for user 'mythtv'@'localhost' to
database 'mythconverg'

Am I scrod? Can anyone tell me how to re-gain root access to my mysql
database?

--
Kevin J. Cummings
kjchome [at] rcn
cummings [at] kjchome
cummings [at] kjc386
Registered Linux User #1232 (http://counter.li.org)
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users


keller.g at gmail

Apr 19, 2007, 11:20 PM

Post #2 of 9 (8227 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

On Fri, 2007-04-20 at 01:58 -0400, Kevin J. Cummings wrote:

> OK, a while ago, I setup MythTV on my home server (with a PVR-350 card)
> on FC5 before Jarod had updated his instructions for FC5. I muddled
> through the installation, using a combination of the FC4 and FC3
> instructions, and using RPMS from ATRPMS, I got MySQL, ivtv, and mythtv
> all installed an running. Woo Hoo!
>
> I was able to add a new PC5500-HD card to my setup this past Christmas
> without any problem. Great! Cool!
>
> Now, I want to add a remote frontend. This requires a change to the
> MySQL setup. I have to issue a GRANT command like so:
>
> > $ mysql -u root mythconverg
> > mysql> grant all on mythconverg.* to mythtv@"%" identified by "mythtv";
> > mysql> flush privileges;
>
> My problem? When I try and login to mysql I can't remember the password
> I used for root! I am able to login as mythtv, but trying to issue the
> "grant all" command gives me:
>
> ERROR 1044 (42000): Access denied for user 'mythtv'@'localhost' to
> database 'mythconverg'
>
> Am I scrod? Can anyone tell me how to re-gain root access to my mysql
> database?
>

NOTE: Posted in the right place this time. List gods, please don't
smite me! =(

There may be a more elegant solution, but here's what I did when I
accidentally deleted the MySQL root account once (!).

Use the following command to dump your database to disk.

mysqldump -u mythtv -p mythconverg -c > mythtv_backup.sql

In Ubuntu, I just go into Synaptic and tell it to "Completely remove"
the MySQL server. This basically strips everything MySQL server off the
system including configuration files.

Now, reinstall MySQL server - you'll have a clean slate. Change the
root password to "password" or something else easy to remember. =P

Now use the following commands to restore your database.

$ mysql -u root -p
mysql>create database mythconverg;
mysql>exit
$ mysql -u mythtv -p mythconverg < mythtv_backup.sql


That should restore your data correctly and give you a fresh database with a root password you know.

Good luck!

-Keller

Reference : http://www.mythtv.org/wiki/index.php/User_Manual:Periodic_Maintenance


aristide at tiscali

Apr 19, 2007, 11:25 PM

Post #3 of 9 (8237 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

Kevin J. Cummings wrote:
>
> Am I scrod? Can anyone tell me how to re-gain root access to my mysql
> database?
>
AFAIK, you can edit the configuration file of mysql in a way, that it
bypasses security (and doesn't ask for any password).

You can then change the root password, and afterwards set the security
settings back.

I don't remember the exact way, but googling with something like that 'lost
root password mysql' should lead you to the right place(s).

Yann

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


cummings at kjchome

Apr 19, 2007, 11:53 PM

Post #4 of 9 (8250 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

Keller Giacomarro wrote:
>
> NOTE: Posted in the right place this time. List gods, please don't
> smite me! =(
>
> There may be a more elegant solution, but here's what I did when I
> accidentally deleted the MySQL root account once (!).
>
> Use the following command to dump your database to disk.
>
> mysqldump -u mythtv -p mythconverg -c > mythtv_backup.sql
>
> In Ubuntu, I just go into Synaptic and tell it to "Completely remove"
> the MySQL server. This basically strips everything MySQL server off the
> system including configuration files.
>
> Now, reinstall MySQL server - you'll have a clean slate. Change the
> root password to "password" or something else easy to remember. =P

Thanks! B^)

> Now use the following commands to restore your database.
>
> $ mysql -u root -p
> mysql>create database mythconverg;
> mysql>exit
> $ mysql -u mythtv -p mythconverg < mythtv_backup.sql

Worked like a champ!

>
> That should restore your data correctly and give you a fresh database with a root password you know.
>
> Good luck!
>
> -Keller

--
Kevin J. Cummings
kjchome [at] rcn
cummings [at] kjchome
cummings [at] kjc386
Registered Linux User #1232 (http://counter.li.org)
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users


dave at cpfc

Apr 20, 2007, 12:24 AM

Post #5 of 9 (8253 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

The correct way

stop mysql

/usr/bin/mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
use mysql;
UPDATE user SET Password=PASSWORD("somepassword") WHERE User="root";

start mysql
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users


keller.g at gmail

Apr 20, 2007, 12:27 AM

Post #6 of 9 (8235 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

On Fri, 2007-04-20 at 08:24 +0100, David Campbell wrote:
> The correct way
>
> stop mysql
>
> /usr/bin/mysqld_safe --skip-grant-tables --skip-networking &
> mysql -u root
> use mysql;
> UPDATE user SET Password=PASSWORD("somepassword") WHERE User="root";
>
> start mysql
> _______________________________________________
> mythtv-users mailing list
> mythtv-users [at] mythtv
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

Told you there was a more elegant way. =)

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


mtdean at thirdcontact

Apr 20, 2007, 7:26 AM

Post #7 of 9 (8233 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

On 04/20/2007 02:20 AM, Keller Giacomarro wrote:
> On Fri, 2007-04-20 at 01:58 -0400, Kevin J. Cummings wrote:
>> My problem? When I try and login to mysql I can't remember the password
>> I used for root! I am able to login as mythtv, but trying to issue the
>> "grant all" command gives me:
>>
> NOTE: Posted in the right place this time. List gods, please don't
> smite me! =(

Did someone sign me up for the MySQL mailing list? If so, please remove
me from that list...

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


mtdean at thirdcontact

Apr 20, 2007, 7:46 AM

Post #8 of 9 (8219 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

On 04/20/2007 03:24 AM, David Campbell wrote:
> The correct way
>
> stop mysql
>
mysqld
> /usr/bin/mysqld_safe --skip-grant-tables --skip-networking &
> mysql -u root
> use mysql;
> UPDATE user SET Password=PASSWORD("somepassword") WHERE User="root";
>
exit

stop mysqld
> start mysql
mysqld


However, the correct correct way is:

stop mysqld (as appropriate for your system, i.e. using init scripts or
whatever)

touch /srv/mysql/tmpinit.sql &&
chmod 600 /srv/mysql/tmpinit.sql &&
cat > /srv/mysql/tmpinit.sql << EOF
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('not this password');
SET PASSWORD FOR 'root'@'`hostname`' = PASSWORD('not this password');
EOF
mysqld_safe --user=mysql \
--init-file=/srv/mysql/tmpinit.sql 2>&1 >/dev/null &
rm /srv/mysql/tmpinit.sql

The "other" correct way runs mysqld without a password /and/ bypasses
the permissions system, which is not desirable. The other approach
requires restarting mysqld twice (there should be a "stop mysqld" after
the UPDATE)--this one only requires one restart. The other approach
puts root's password in the ~/.mysql_history of the user running the
mysql command-line client.

With the approach I recommend, it's desirable to write the tmpinit.sql
file to a location that is not generally accessible by users, so there
is no indication that someone is hacking the DB (which could encourage
attempted timing attacks). However, by touching the file first and then
explicitly setting its permissions, we minimize the chances of someone
seeing the actual password. Because the password is only in a here
document, it is not a part of the "ps" command list or put into
~/.bash_history or ...

But, I don't need to worry about security! So, why are you even running
mysql with a password.

On my systems, every single mysql server has a different root password.
No one (not even me) knows those passwords. This wouldn't be possible
if I needed 24/7/52 access, but, hey, my hardware's not that reliable.
As a matter of fact, it's really not even necessary to log in as root.

Huh? How can I allow access from other hosts without logging in as
root? Well, if you don't know the root password and you don't want to
know it, you can just replace the "SET PASSWORD" lines with:

GRANT ALL ON mythconverg.* TO mythtv@"%" IDENTIFIED BY "mythtv";
FLUSH PRIVILEGES;

However, I highly recommend setting the password to a nice complex
password at least once. To do that, you can just add the GRANT and
FLUSH lines to the here document after the SET PASSWORD lines and do
them all at once.

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


newbury at mandamus

Apr 20, 2007, 9:30 AM

Post #9 of 9 (8213 views)
Permalink
Re: What to do when you can't remember the password for mysql [In reply to]

Kevin J. Cummings wrote:
> OK, a while ago, I setup MythTV on my home server (with a PVR-350 card)
> on FC5 before Jarod had updated his instructions for FC5. I muddled
> through the installation, using a combination of the FC4 and FC3
> instructions, and using RPMS from ATRPMS, I got MySQL, ivtv, and mythtv
> all installed an running. Woo Hoo!
>
> I was able to add a new PC5500-HD card to my setup this past Christmas
> without any problem. Great! Cool!
>
> Now, I want to add a remote frontend. This requires a change to the
> MySQL setup. I have to issue a GRANT command like so:
>
>> $ mysql -u root mythconverg
>> mysql> grant all on mythconverg.* to mythtv@"%" identified by "mythtv";
>> mysql> flush privileges;
>
> My problem? When I try and login to mysql I can't remember the password
> I used for root! I am able to login as mythtv, but trying to issue the
> "grant all" command gives me:
>
> ERROR 1044 (42000): Access denied for user 'mythtv'@'localhost' to
> database 'mythconverg'

User mythtv is not authorized to create new users so that access is denied.

User 'root' in mysql is orginally created with NO password, Did you try:

su - <enter>
mysql -u root -p<enter>

That might get you in.

Otherwise follow the instructions here:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

And read the comments on that page: they discuss some 'gotchas'.


> Am I scrod? Can anyone tell me how to re-gain root access to my mysql
> database?

Pedantic nitpick... That should be 'Be I scrod?' since of course,
'scrod' is the subjunctive form of the verb......LOL


--
R. Geoffrey Newbury
Barrister and Solicitor
Suite 106, 150 Lakeshore Road West
Mississauga, Ontario, L5H 3R2

o905-271-9600 f905-271-1638
newbury [at] mandamus

Helping with the HTTP issue
<a href="http://www.w3.org/Protocols/">HTTP</a>
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://mythtv.org/cgi-bin/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.