Your Ad can be there
+ Post New Thread
Results 1 to 2 of 2

Thread: How to speed up manual process of resetting all MySQL passwords on WHM/cpanel server?

  1. #1
    Administrator
    Join Date
    Mar 2013
    Posts
    2,724

    How to speed up manual process of resetting all MySQL passwords on WHM/cpanel server?

    How to automate manual task replacing legacy MySQL passwords by new ones on WHM/cPanel server and in user's .php files?
    This task may be needed in case one migrate from old MySQL to new one. In such a case the mysql passwords are automatically reseted:

    The system changed the password for the database user "myzom" to a random string because the original password used an old and insecure format that is incompatible with MySQL version 5.6.17. You must manually change the password for "username" to match the original password in order to ensure that applications that use the credentials will continue to function
    leaving files with old outdated passwords, causing sites unable to connect MySQL. More about that here.
    So how to as quickly as possible change all the passwords in files?

    Here is the process:

    1. Go to new server WHM into section SQL Services > Change MySQL User Password
    2. Rewrite first mysql username to the following command which you will execute on the server command line:

    grep -C 4 -Ri "userhere_name" /home/userhere/public_html

    3. From the results of the above command, copy old password to some temporary place, example browser search box.
    4. proceed with the password reset on WHM page opened in step 1 and copy also new password.
    5. WHM will say: You have successfully changed “mysqlusername”’s MySQL password.
    6. Replace old password by new one in files:

    for file in $(find /home/userhere/public_html -type f);do sed -i "s|oldpassword|newpassword|g" 2>/dev/null;done

    ---
    Another approach can be to create script to list all mysql users, find .php files that contain that mysql username and also phrase: "localhost" or 'localhost'
    manually read and copy old password
    Do password generating/reset command for the username
    Do search and replace command in files to replace old copied password by new password.

    If you find easier way to complete the process, please kindly share it.

  2. #2


    Is this useful / helpfull? Yes | No
    If you want to reset MySQL root password then you can easily do this. It is must to have root access of server.
    You have to reset MySQL root password on Centos server.

+ Post New Thread

Similar Threads

  1. WTS V&WEB Cpanel web Hosting From 7.9/month - MySQL
    By Kate@V&Web in forum Cloud: Offers & Requests
    Replies: 0
    Last Post: 03-28-2018, 09:31 AM
  2. Replies: 0
    Last Post: 08-31-2017, 01:55 PM
  3. Unable to import mySQL database for CPanel webhosting?
    By webc in forum PHP, MySQL Forum
    Replies: 1
    Last Post: 03-23-2014, 03:18 PM
  4. Replies: 1
    Last Post: 03-23-2014, 01:46 PM
  5. Replies: 0
    Last Post: 01-05-2014, 08:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam