change wordpress password manually

Reset wordpress password using provided link not work, sadly no phpmyadmin available 🙂

Fortunately I have shell access which is enough, using built in md5 function to generate and update the password, here’s the steps:

1. Creating md5

– Using shell

Just type :

md5 -s your chosen password

– Make php script with this content :

<?php

$string=’your chosen password’;

echo md5($string);

?>

save this script and execute on your server.

2. Update wordpress table

– Using shell

login to mysql with username and password that written in wp-config.php

mysql -uusername -ppassword -pdatabase_name;

use database_name;

update user table set password=’md5 generated hash’ where username=’current_username’;

– Using php script

Make this script

<?php

$con=mysql_connect(“localhost”,”username_db”,”password_db”);

$choose=mysql_select_db(“db_name”);

//updating table

$update=mysql_query(“update table_user set password=’md5 generated hash’ where username=’current_username'”);

?>

save this script as change.php, upload to server and execute.

Done.

I can login to my wordpress account again.

$this and php

Little mistake on naming variable make me confuse for almost an hour.

$this

yes, $this is built-in variable that often use in OOP. By using $this, we refer to self referencing variable.

More in php.net manual

<?php
class A
{
function
foo()
{
if (isset(
$this)) {
echo
'$this is defined (';
echo
get_class($this);
echo
")\n";
} else {
echo
"\$this is not defined.\n";
}
}
}

class B
{
function
bar()
{
A::foo();
}
}

$a = new A();
$a->foo();
A::foo();
$b = new B();
$b->bar();
B::bar();
?>

Install PHP6, easy install in windows

PHP6, I thought I already have latest one. 5.2.6 but I’m wrong 🙂

Quick way to try PHP6 is by installing Appserv 2.6.0, click here to download php 6.0.0-dev

Installation process is the same as other appserv series :

1. Double click installer

php6 read more »

Setting path for PHP CLI

What is that for?

my friend asked my a question after lunch.

Well, install php using file from php.net don’t automatically set environment path for php location.

As result we must type full location of php.exe each time we must execute php from command line.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>php -v
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

C:\Documents and Settings\Administrator>cd ..

C:\Documents and Settings>php -v
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

C:\Documents and Settings>d:

D:\>php -v
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

D:\>

Yes, by setting path for php we can execute php.exe from any place in windows.

To set that path, just right click on My Computer:

Click Advance

Environment variables for input php location.

I install php in c:\php.

Click OK.

Done 🙂

Reset Cacti Password, step by step

My other staff  ask me password for username admin. Yes, its administrator level in cacti.

After hardy trying to remember I gave up, I decide to reset it to other value but how?

I try to find out using database approach :

Here’s my steps :

1. Checking for cacti location and see db setting.

monitor# pwd

/usr/local/share/cacti/include

see setting dbnya.

monitor# cat db-settings.php

<?php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";

$database_port = "3306";
?>

2. Enter database with information taken from db-settings.php information.

monitor# mysql -ucacti -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8343
Server version: 5.0.45 FreeBSD port: mysql-server-5.0.45_1

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

mysql> use cacti;

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select * from auth_user;

ERROR 1146 (42S02): Table ‘cacti.auth_user’ doesn’t exist

Ups, my bad 🙂

mysql> select * from user_auth;

+—-+———-+————-———————+——-+—————+————–——–+———–+———–+————–+—————-+————+—————+————–+———–—+————————+
| id | username | password                         | realm | full_name     | must_change_password | show_tree | show_list | show_preview | graph_settings | login_opts | policy_graphs | policy_trees | policy_hosts | policy_graph_templates |
+—-+———-+————-———————+——-+—————+————–——–+———–+———–+————–+—————-+————+—————+————–+———–—+————————+
|  1 | admin    | 7a40008b8368b684bec2286db1b073e2 |     0 | Administrator |                      | on        | on        | on           | on             |          1 |             1 |            1 |            1 |                      1 |
|  3 | monitor  | 719daab8833968dc805a345c58545ea6 |     0 | monitoring    |                      | on        | on        | on           | on             |          3 |             1 |            1 |            1 |                      1 |
|  7 | crash    | ac43724f16e9241d990427ab7c8f4228 |     0 | Nsun T        |                      | on        | on        | on           | on             |          3 |             1 |            1 |            1 |                      1 |
+—-+———-+————-———————+——-+—————+————–——–+———–+———–+————–+—————-+————+—————+————–+———–—+————————+
3 rows in set (0.00 sec)

mysql>exit

3. Generate new password with md5 utility.

monitor# md5 -s mypassword

MD5 ("mypassword") = 34819d7beeabb9260a5c854bc85b3e44

4. Update database value with new created password string.

monitor# mysql -ucacti -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8344
Server version: 5.0.45 FreeBSD port: mysql-server-5.0.45_1

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

mysql> update auth_user set password=’34819d7beeabb9260a5c854bc85b3e44′ where username=’admin’

done 🙂