To change the database user password from cPanel:


1. Log into cPanel.

2. Click on “MySQL databases” under the databases tab.

3. Scroll down. There is an option to change DB user password.

To change the database user password using bash script:

1. SSH to the server.

2. Create a file “checkdb.sh“.

3. Change to X mode.

chmod +x checkdb.sh


4. Add the following code:

#!/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.rootadminz.com/change-database-user-password-cpanel/";;
  * ) echo "Not a valid option.";;
esac


Change the code as you need.


5. Execute

sh checkdb.sh


Read the instructions and update passwords…


That’s it!

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)