Changing database password fails

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
jwdonal
Regular
Posts: 14
Joined: Sat Mar 06, 2010 1:40 am
Contact:

Changing database password fails

Post by jwdonal »

Hello all,

I have 3 serendipity blogs on my site. They all run great and I've never had any problems with them. Long story short, I've been performing some maintenance operations on my server and I noticed that the password to my serendipity database is way too simple. So I thought I would be a good boy and make it more complex. Unfortunately, this wasn't so easy. Here is what I did:

1) Updated the 'dbPass' value in "serendipity_config_local.inc.php" to 'MY_NEW_P@$$'
2) Ran the following SQL to update serendipity's postgres password:

Code: Select all

su - postgres
psql -d template1 -c "ALTER USER serendipity WITH PASSWORD 'MY_NEW_P@$$';"
Then I refresh my blog and I get:

Code: Select all

serendipity error: unable to connect to database - exiting.
What am I forgetting to change? :( It seems like it should be so simple...no?

Thanks!
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Changing database password fails

Post by Timbalu »

Since the password is hashed, you can't do it via sql directly.

The best would be to change it inside the admin panel.

If you can't do so anymore, he only way to access is to try this.

Add a file "fixlogin.php" with:

Code: Select all

    <?php
    $username = "usernameold";
    $password = "newpwset";
    include 'serendipity_config.inc.php';
    echo serendipity_db_query("UPDATE {$serendipity['dbPrefix']}authors SET password = '" . serendipity_hash($password) . "', hashtype=1 WHERE username = '" . serendipity_db_escape_string($username) . "'");
    echo "Password changed.";
and call it via http://yourblog/fixlogin.php. Do not forget to change $username and $password to your own setting.

The s9y serendipity_hash() function will then convert your new password truly.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Re: Changing database password fails

Post by kleinerChemiker »

Timbalu wrote:Since the password is hashed, you can't do it via sql directly.
Try this. Add a file "fixlogin.php" with:

Code: Select all

    <?php
    $username = "usernameold";
    $password = "newpwset";
    include 'serendipity_config.inc.php';
    echo serendipity_db_query("UPDATE {$serendipity['dbPrefix']}authors SET password = '" . serendipity_hash($password) . "', hashtype=1 WHERE username = '" . serendipity_db_escape_string($username) . "'");
    echo "Password changed.";
and call it via http://yourblog/fixlogin.php. Do not forget to change $username and $password to your own setting.

The s9y serendipity_hash() function will then convert your new password truly.
He changed the DB password, not an user pw.

Try restarting your DB.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Changing database password fails

Post by Timbalu »

kleinerChemiker wrote:He changed the DB password, not an user pw.
Ooh :oops:
Sorry for this, thank you clearing this up.
Please erase the unnecessary copy.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
jwdonal
Regular
Posts: 14
Joined: Sat Mar 06, 2010 1:40 am
Contact:

Re: Changing database password fails

Post by jwdonal »

kleinerChemiker wrote:Try restarting your DB.
Yip, I restarted my DB. Made sure the process was completely stopped as well. And then started again. Serendipity still fails to connect... :(
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Re: Changing database password fails

Post by kleinerChemiker »

Then your pw seems to wrong. I don't know the right syntax for postgres but are you sure, you did it right?
jwdonal
Regular
Posts: 14
Joined: Sat Mar 06, 2010 1:40 am
Contact:

Re: Changing database password fails

Post by jwdonal »

kleinerChemiker wrote:Then your pw seems to wrong. I don't know the right syntax for postgres but are you sure, you did it right?
Yep, I'm sure. I've changed many passwords like that. And, in fact, if I run the exact same command but with the old password (and also update the serendipity config file), then everything starts working again. I've tried these combinations:

1) Edit serendipity config back to old password, leave DB with new password. BROKEN
2) Leave serendipity with new password, edit DB to have old password. BROKEN
3) Edit both serendipity and DB back to having old passwords. WORKS!

What the?? It's literally like it just doesn't want to change from the old password. Also, I tried changing another user's DB password using the same method as shown above and I could log in to the DB with the new password that I set. So the DB command to change the password is correct.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Changing database password fails

Post by Timbalu »

Maybe I can help though ;-)
I don't know a postgres db, but I think you might need to set a md5(), like

Code: Select all

"ALTER USER serendipity WITH PASSWORD md5('MY_NEW_P@$$');"
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
jwdonal
Regular
Posts: 14
Joined: Sat Mar 06, 2010 1:40 am
Contact:

Re: Changing database password fails

Post by jwdonal »

When I change the DB password it automatically creates an md5 hash of the clear-text password from the command-line (and I have verified that). So, unfortunately, no that won't fix it... :(
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Re: Changing database password fails

Post by kleinerChemiker »

Do you have a software like phpmyadmin to connect to your db to test the new password?
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Changing database password fails

Post by Timbalu »

isn't there any db error log output when trying to set the password?
Just to test - simplify your new password and try again.
Maybe its some sort of length or unusual char error.
Did you Server upgrade change the Database?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
jwdonal
Regular
Posts: 14
Joined: Sat Mar 06, 2010 1:40 am
Contact:

Re: Changing database password fails

Post by jwdonal »

Timbalu wrote:...or unusual char error...
Holy cra*. You're right! I changed the new pass to only use [a-z][A-Z][0-9] and it works now. What the heck kind of junky password system is it that can't take special chars??? Lame.

Thanks for your help guys!! :-D
Post Reply