User Tools

Site Tools


wordpress_password_reset

This is an old revision of the document!


| wpreset.sh
#!/usr/local/bin/bash
# Wordpress Password Reset
# <Ketan Patel> [email protected]
 
if [ $# -lt 2 ]
then
   echo "Usage: $0 <Blog Location> <new Password> [<Admin User>]"
elif [ $# -lt 3 ]
then
   WPUser='admin'
else
   WPUser=$3
fi
 
RESET="UPDATE wp_users SET user_pass=MD5('$2') WHERE user_login='$WPUser'"
 
cd $1
 
DBNAME=`grep DB_NAME wp-config.php | cut -d "'" -f 4`
DBPASS=`grep DB_PASSWORD wp-config.php | cut -d "'" -f 4`
DBHOST=`grep DB_HOST wp-config.php | cut -d "'" -f 4`
DBUSER=`grep DB_USER wp-config.php | cut -d "'" -f 4`
 
if mysql -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME -e "$RESET"
then
        echo "new password set to '$2'"
else
        echo "Failed!!"
fi
 
exit
wordpress_password_reset.1288482622.txt.gz · Last modified: 2010/10/30 19:50 by k2patel