The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SQL password issue when migrating to new server

Discussion in 'Database Discussions' started by Oliver hills, Nov 13, 2015.

  1. Oliver hills

    Oliver hills Registered

    Joined:
    Nov 13, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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!
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  3. Oliver hills

    Oliver hills Registered

    Joined:
    Nov 13, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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
    
    
     
    #3 Oliver hills, Nov 17, 2015
    Last edited by a moderator: Nov 17, 2015
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page