SQL password issue when migrating to new server

Oliver hills

Registered
Nov 13, 2015
2
0
1
Perth Australia
cPanel Access Level
Root Administrator
I'm in the process of moving all our users onto a new server and due to the versions of MYSQL being different between the two our users database passwords are getting reset to a random string. Most of our users aren't too technically literate and would have no idea what their database passwords were without consulting a Web Developer which will cost them money.

I'm wondering if anyone has any neat tricks for finding the database passwords?

I know I can't get them out of MYSQL as they are irreversibly encrypted but I was thinking that I may be able to find a few them in the users config files, the one liner below is what I have so far but it's spitting out way more lines than just what I want.

egrep -r -H "password|Password|PASSWORD" /home/ |egrep "db|DB|db|database"

I'm also wondering if there is an easy way to make mysql on the old server convert all it's passwords to the new longer hashes but from the reading I have done so far that would require knowing the old passwords.

So If anyone has any suggestions or guidance that would be great!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463
Hello :)

The method you are planning to use (obtaining the password from the script configuration files) is likely the most reliable method. It might be time-consuming, but many applications do store the database password in a configuration file in plaintext.

Thank you.
 

Oliver hills

Registered
Nov 13, 2015
2
0
1
Perth Australia
cPanel Access Level
Root Administrator
Sorry for bumping an older thread but I thought the below script may help for others in the same situation, it currently finds WordPress and Joomla passwords in the root of a users public_html. It's not pretty as I couldn't be bothered to fix egrep for the Joomla search but it works!

Code:
#!/bin/bash

cd /home/
users=($(ls -d */ |grep -v tmp))

for user in "${users[@]}"
do
  path=/home/$user'public_html/'
  if [ -f $path'wp-config.php' ]
  then
  printf '\n%s\n' 'WORDPRESS config found for user '$user
  cat $path'wp-config.php' |egrep "DB_NAME|DB_USER|DB_PASSWORD"
  elif [ -f $path'configuration.php' ]
  then
  printf '\n%s\n' 'JOOMLA config found for user '$user
  cat $path'configuration.php' |grep "\$db "
  cat $path'configuration.php' |grep "\$user "
  cat $path'configuration.php' |grep "\$password "
  fi
done
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463
Thank you for taking the time to provide that workaround.