mysql selecting all databases under account

6 replies
I need to update all WordPress admin passwords under my hosting account.

I have around 50 databases and have the following code:
Code:
UPDATE 'wp_users' SET 'user_pass' = MD5('f0a537c1e86d9f6ca73c06b71bc94ce1') WHERE 'user_login' ='admin' LIMIT 1;
How can I set this to work on all databases? Since the tables are all the same in each database, I figured there was a faster way than going through each one and copy/pasting this.

Thanks

edited:::
using SQL query under phpmyadmin.
#account #databases #mysql #selecting
  • Profile picture of the author Andrew H
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[6532495].message }}
  • Profile picture of the author SteveSRS
    You would have to log in as root (or any user with access to all db's)
    then do something like:

    use dbname;
    UPDATE 'wp_users' SET 'user_pass' = MD5('f0a537c1e86d9f6ca73c06b71bc94ce1') WHERE 'user_login' ='admin' ;
    and repeat these 2 lines for every db then run it.

    Otherwise I would make a small php script to do it if I where you
    {{ DiscussionBoard.errors[6532644].message }}
  • Profile picture of the author underthegun
    When I first login to phpmyadmin, before selecting a database, I do have an option to run a SQL query.

    So I could use...

    use dbname; use dbname1; use dbname2; use dbname3;

    and so on?

    or I HAVE to be logged in as root?
    Signature

    {{ DiscussionBoard.errors[6532678].message }}
    • Profile picture of the author burton247
      As SteveSRS said use:

      Code:
      use dbname;
      UPDATE 'wp_users' SET 'user_pass' = MD5('f0a537c1e86d9f6ca73c06b71bc94ce1') WHERE 'user_login' ='admin' ;
      
      
      use dbname1;
      UPDATE 'wp_users' SET 'user_pass' = MD5('f0a537c1e86d9f6ca73c06b71bc94ce1') WHERE 'user_login' ='admin' ;
      
      
      use dbname2;
      UPDATE 'wp_users' SET 'user_pass' = MD5('f0a537c1e86d9f6ca73c06b71bc94ce1') WHERE 'user_login' ='admin' ;
      And then run it. You don't have to be logged in as root but it will need to be a user that has access to all DBs
      {{ DiscussionBoard.errors[6536481].message }}
  • Profile picture of the author SteveSRS
    exactly what burton247 said, root is not necessary (like I said) but you need an account with access to all db's normally this should only be root as for every website I use another account (security purposes and also anti-overload purposes concerning max requests per user)
    {{ DiscussionBoard.errors[6539809].message }}

Trending Topics