simple sql for mass changing passwords

Changing password for user 1 looks like this:

UPDATE `mydb`.`wp_users` 
   SET `user_pass` = MD5( 'password' ) 
 WHERE `wp_users`.`ID` = 1;

Now, I have text file with such format:

Read More
user30 pass30
...
user2 pass2
user1 pass1

How can I change passwords for all these users without doing it manually? Maybe some sql command that could import it from this file? Or some other method? I’m using phpmyadmin, maybe I can import that data into these specific fields somehow?

I want to only import password 5 and greater.

Related posts

Leave a Reply

1 comment

  1. I don’t know of any SQL that will import for an update like that. However, you could import the file into a table (let’s call it ‘password_changes’) with username and new_password fields, and then do something like

    UPDATE wp_users, password_changes
    SET wp_users.user_pass = md5(password_changes.new_password)
    WHERE wp_users.user_login = password_changes.username
    

    The statement above will change passwords for only those users listed in your file (and thus imported into the password_changes table). However, if you want to be extra sure users 1-4 don’t get changed, add AND wp_users.ID >= 5 to the query.