This shows you the differences between two versions of the page.
wordpress_password_reset [2010/10/30 23:50] k2patel |
wordpress_password_reset [2020/08/10 02:35] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code bash | wpreset.sh> | ||
- | #!/usr/local/bin/bash | ||
- | # Wordpress Password Reset | ||
- | # <Ketan Patel> k2patel@hotmail.com | ||
- | 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 | ||
- | </code> |