11

I have one hosting account using cPanel and phpmyadmin.

I have 50 databases under this account, all WordPress.

I need this query modified so that it runs through all databases to update the password.

UPDATE 'wp_users' SET 'user_pass' = MD5('somepassword') WHERE 'user_login' ='admin' LIMIT 1;

Hoping for a solution that can target all databases instead of having to go through them one by one.

Thank you

Billy
  • 111
  • 1
  • 1
  • 3

2 Answers2

11

I can't say anything about cPanel and phpmyadmin but In general i can do it by writing a simple script.

I have written a shell script for you

#!/bin/bash

# mysql credential 
user="root"
pass="root"

# list of all databases
all_dbs="$(mysql -u $user -p$pass -Bse 'show databases')"        

for db in $all_dbs
     do
        if test $db != "information_schema" 
            then if test $db != "mysql" 
            then mysql -u$user -p$pass $db -sN -e "UPDATE wp_users SET user_pass = MD5('somepassword') WHERE user_login ='admin' LIMIT 1;"
        fi
    fi  
     done
Abdul Manaf
  • 9,587
  • 16
  • 73
  • 84
8

Try running this and then cut n paste the output back into phpMyAdmin

SELECT CONCAT('UPDATE `',     
    schema_name, '`.\'wp_users\' SET \'user_pass\' = MD5(\'somepassword\') WHERE \'user_login\' =\'admin\' LIMIT 1;')
FROM information_schema.schemata
WHERE schema_name NOT IN ('information_schema','mysql','performance_schema','test');

or, if you are able to install code on this server, install Common Schema by Shlomi Noach and execute the following QueryScript

call common_schema.foreach( 'schema', "UPDATE `${schema}`.`wp_users` SET 'user_pass' = MD5('somepassword') WHERE 'user_login' ='admin' LIMIT 1");
dan carter
  • 103
  • 3
Aaron Brown
  • 5,140
  • 25
  • 25