Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bulk database user password script
#!/bin/sh
echo "This script is useful for only commonly using CMSs like WP, Joomla, Drupal, Magento, Drupal etc with known configuration location. If nothing listing and you are getting db conntction error check configuration manually.. Thanks by Arunlal"
echo "" > details.txt
echo "Please enter the cPanel username: "
read username
grep -irl ${username}_ /home/$username/*{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php 2>/dev/null grep -v -E "mail|error_log|sql|html|var">> ${username}confs.txt
var=`cat ${username}confs.txt`
if [ -n "$var" ]; then
for i in `cat ${username}confs.txt`; do echo $i >> details.txt; grep -E "DB_USER|user|username|DB_PASSWORD|secret|password" $i |grep -v -E "cookies|generate" >> details.txt; echo "-------" >> details.txt; done
echo " "
echo "***Websites' conf and db details are listed below***"
echo "----------------------------------------------------"
cat details.txt
echo " " > ${username}confs.txt
else
echo "Check the database prefix manually. It seems username and db prefix are not same. Please quit the script. Enter (N/n)!!"
fi
rm -f ${username}confs.txt
read -p "Do you wanna reset the password from here? (y/n)?" choice
case "$choice" in
y|Y ) echo "Alright!! Please give me the following details..."
echo "Enter database username: "
read dbur
echo "Enter current db user password per site's configuration: "
read dbpw
echo "Enter new/same password: "
read dbpwnw
echo "Please wait...... Updating db user $dbur password..."
mysqladmin -u $dbur -p$dbpw password $dbpwnw
echo "Congratulations... DB user password has been updated";;
n|N ) echo "No problem dude.. Reset it from the control panel. Refer https:/www.crybit.com/change-database-user-password-cpanel/";;
* ) echo "Not a valid option.";;
esac
@ashokarun

This comment has been minimized.

Copy link
Owner Author

commented Oct 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.