teh interwebz
RSS icon Home icon
  • phpBB admin password manual reset

    Posted on March 31st, 2009 Josh Highland No comments

    phpbb_logo

    Today I ran into a situation where I had forgotten the password to my development instance of phpBB 3. I was stuck in a situation were I needed to reset the password. I had full admin access to the database, so changing it there wouldn’t be the problem. The real problem is that phpBB uses its own password hashing, not MD5.

    In a work around, I created a new user and used the password “123456″ looking at the database , in the users table of the phpBB install. I saw the “user_password” field was “e10adc3949ba59abbe56e057f20f883e”.

    I then changed my admin accounts user to the same string, “e10adc3949ba59abbe56e057f20f883e”.

    phpbbpasswordreset

    I went to the phpBB login screen, fillled out my username, and entered the password “123456″… BINGO! it worked.

    So to save you the work. You can follow what I did or just use these hashes to reset your own password:

    Hash: e10adc3949ba59abbe56e057f20f883e
    Password: 123456

    Hash: $H$9Ae3Uk.ECdWW5ya13M4ErWhr4c.761/
    Password: password

    I hope this helps someone else out there.

  • Manually reset your WordPress password

    Posted on February 13th, 2009 Josh Highland No comments

    lost-wordpress-password

    It doesn’t matter what application your working with, losing your password is always a pain in the ass. Luckly if you are working with wordpress (man, I blog a lot about wordpress these days), on your server and you have access to the MySql database, resetting your password manually is a snap.

    • Login to your PhpMyAdmin
    • Select your WordPress database and click on the “SQL” button to open the SQL query window.

    wordpress-phpmyadmin

    • Paste the following code in the window textarea. (Don’t forget to modify the password and username before executing it)

    UPDATE ‘wp_users’ SET ‘user_pass’ = MD5(’PASSWORD’) WHERE ‘user_login’ =’admin’;

    That’s it! Your password has been reset, and you should be able to login to your wordpress admin area once again.

    
    								
  • Solution for: MySQL server has gone away at mysqlhotcopy line 528

    Posted on January 19th, 2009 Josh Highland No comments

    mysql-logo

    Recently I was backing up a large MySql database (several hundred megabytes), using the awesome MySqlHotCopy script, when I started getting the following error:

    DBD::mysql::db do failed: MySQL server has gone away at mysqlhotcopy line 528.

    I have no clue what that error means. mysqlhotcopyworked great on all of my other smaller databases. I did a little searching on my old friend google, and after sniffing around a bit, I came up with a resolution to the problem… the script was timing out, so I just had to increase the allowed time in the /etc/my.cnf file.

    Here are the steps I took

    pico /etc/my.cnf

    add these lines to the file:
    interactive_timeout = 3600
    wait_timeout = 3600

    save file

    /etc/init.d/mysqld restart

    I ran mysqlhotcopy again, and everything worked and the backup was made.

  • php sprintf + sql like

    Posted on July 6th, 2008 Josh Highland 9 comments

    Sometimes I do my best programming when I’m tired. Don’t ask me why, I just do. It’s a skill I picked up in college.

    Being tired and producing good code wasn’t the case last night. I was trying to use the sprintf PHP function with a SQL “Like” statement. I made some dumb mistakes that tripped me up for a while. Hopefully someone out there will find this post and help them not make the problems I made, sleepy or not!

    Normally the LIKE is used in mysql like this:
    SELECT name FROM users WHERE name LIKE 'J%';

    That would get all names including: Josh, Jason, Jimi, etc.
    In a SQL Like statement the % is a wild card, so the command is to match everything starting with “J”

    Now when you use the sprintf() function it looks kind like this:
    $query = sprintf("SELECT name FROM users WHERE name='%s'", $searchString);
    The %s will be replaced with the value of $searchString

    Trying to combined them is where I had some problems….

    At first I tried to do something like this:
    $query = sprintf("SELECT name FROM users WHERE name LIKE'%s'", $searchString);
    didnt return what I was looking for at all, it had no wild cards in it!

    Then I tried this:
    $query = sprintf("SELECT name FROM users WHERE name LIKE'%s%'", $searchString);
    didnt work either, this time it threw errors

    But this worked great
    $query =
    sprintf("SELECT name FROM users WHERE name LIKE '%s'", $searchString . "%");

    So the moral of the story is, if you want to use a SQL Like statement, appent the wildcard for the Like statement to the string to be inserted by the sprintf funtion.

  • Select random records in a MySQL database

    Posted on July 16th, 2007 Josh Highland No comments

    mysql-logo.gif
    Say you want to select some random records in a MySQL database. Here is a fast way to do it:

    SELECT *
    FROM tableName
    WHERE conditions
    ORDER BY Rand()

    Using the Rand() function will randomly select the rows. You can limit the number of rows returned by using the LIMIT command