Azharkamar.com

SQL Query in phpMyAdmin to Change All Passwords to MD5

Snippets
24 Oct 2011
2 comments

Hello there folks! Ok, so here’s the story. I had to batch create Joomla users (about 4000 of them) from an excel file that my client provided. So I created all the users successfully (using phpMyAdmin), but there was one problem.

Somehow, all the users that were created from phpMyAdmin aren’t able to login. And I found out it was because the passwords in the database wasn’t encrypted in MD5 format, the default encryption used by Joomla if when you create users via the Joomla backend.

So I guess I had to do it manually. That’s when I came up with this script below that will automatically run through all rows in the database table looking for passwords that aren’t encrypted in MD5 and encrypt it.

MD5 Enryption SQL Query

Here’s how to do it:

  1. Login to your website’s cPanel and click phpMyAdmin.
  2. Select your database from the left panel and then select the table you wish to run this code on.
  3. Click the SQL menu item at the top.
  4. Enter this query and then click the Run button:
    UPDATE ecsconne_users SET `password` = MD5(`password`) WHERE LENGTH(`password`)
    > 0 AND (LENGTH(`password`) != 65 AND LOCATE(':', `password`) != 33)
    AND LENGTH(`password`) != 32
    
  5. Done!

Good luck, coders!

Author - Azhar Kamar
2 Comments Revolving around this Article
  1. Lins

    Quality query. Totally works just change the table name to the one you want. Thanks tons

  2. varl?k

    nice article 8000 saw record job . tnks

Write a Comment! NOW! :)

Current ye@r *