Alister West

home is where your code is ...

Perl - RT - Testing

RT Reset (root) Password

SELECT Name, @ID := id as `@ID`, @TMP_PASS := SUBSTRING( MD5(RAND()) FROM 1 FOR 5 ) as `@TMP_PASS`, @PASSWD := Password as `@PASSWD` FROM Users WHERE id = 12;
UPDATE Users SET Password = md5( @TMP_PASS ) WHERE id = @ID limit 1; # Bypass

# log-in ...

# Revert
UPDATE Users SET Password = @PASSWD WHERE id = @ID limit 1;
SELECT id, Name, Password FROM Users WHERE id = @ID;

RT Change Emails for Testing

# backup usernames/passwords
CREATE TABLE Users_bak SELECT * FROM Users;

SELECT @TMP_PASS := SUBSTRING( MD5( RAND( ) ) FROM 1 FOR 5 );
SELECT @DEV_EMAIL:= 'alister@example.com';

# convert email addresses to 'alister-$Name@example.com'
UPDATE Users SET Name = CONCAT(id, '-', SUBSTRING_INDEX(Name, '@', 1)) WHERE Name like '%@%';
UPDATE Users SET EmailAddress = CONCAT(
            SUBSTRING_INDEX( @DEV_EMAIL, '@', 1 ), '-', SUBSTRING_INDEX( EmailAddress, '@', 1),
            '@', SUBSTRING_INDEX( @DEV_EMAIL, '@', -1 )
        ),
        Password = MD5( @TMP_PASS )
  WHERE EmailAddress LIKE '%@%';
SELECT id, Name, EmailAddress, Password FROM Users LIMIT 10;


# Revert
UPDATE Users u JOIN Users_bak u2 USING(id) 
   SET u.Name = u2.Name, u.EmailAddress = u2.EmailAddress, u.Password = u2.Password;
SELECT id, Name, EmailAddress, Password FROM Users LIMIT 10;
By Alister West