19 September 2014

Five Things People Do to Hurt Their Careers -- And How to Stop Doing Them

Five Things People Do to Hurt Their Careers -- And How to Stop Doing Them

15 September 2014

How to reset the admin username and password for a WordPress blog

More work on the WordPress blog (see previous post). I realized that my permissions were read-only. This article helps; the trick is to edit the user on the wp_users table of the database, ensuring that you choose MD5 as the function to run on the password field, otherwise it won't be encrypted. Though the article covers an older version of MySQL, it's still applicable.

11 September 2014

How to copy a WordPress blog to another Windows machine

Just ran into this today. A friend had a WordPress 4.0 blog set up on his Windows 7 machine across the country. I needed to continue development on it here. I assumed it would be as easy as a few exports/imports. Not so.

He exported the SQL for the blog in MySQL on his machine and zipped his entire WAMP server folder (usually the c:\wamp folder). I downloaded both, ensured my local WAMP server was running, and then ran the exported SQL on MySQL. Then I copied his uploaded WordPress blog instance, wpblog, from his WWW folder into mine.

I went to http://localhost:8080/. The WAMP server came up just fine (running on port 8080 to not conflict with IIS 7, which uses port 80 by default); however, I couldn't load the blog -- clicking it in the list of apps just brought up an error that it couldn't be found. What could be missing?

Well, a look into MySQL showed that it didn't have the wpblog database at all. Even though the exported SQL ran without error, it was run against the wrong database; the wpblog didn't exist. But this was only the tip of the iceberg, so to speak.

The WordPress data had hard-coded URLs (http://localhost/wpblog/) that wouldn't work with the port 8080 on my machine's WAMP setup (http://localhost:8080/wpblog/). To change these links on the data would have been quite a chore. I decided to stop IIS, so I could change WAMP to run on the default port 80 and address the issue with the links.

These were the steps to address the issues:
  1. Opened MySQL admin in the browser.
  2. Created the wpblog database manually via the UI.
  3. Clicked on the new database and opened the SQL tab.
  4. Pasted and ran the exported SQL from the friend's MySQL database. This created the tables and their data for WordPress to function (this included all the posts the friend had entered in WordPress).
  5. Went to Start button and typed cmd into the search box.
  6. This brought up cmd.exe at the top of the Start menu.
  7. Right-clicked cmd.exe and selected "Run as administrator".
  8. Clicked Yes on the User Access Control popup.
  9. In the elevated command window, typed net stop WAS to stop IIS. (You can use net start W3SVC to restart IIS later.)
  10. Opened the Apache configuration file (usually stored at C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf) with Notepad and changed the ports to ensure they pointed to port 80 and not 8080: Listen 0.0.0.0:80 and Listen [::0]:80
  11. Ensured I had successfully copied the wpblog folder (the WordPress blog instance in this case) from the uploaded wamp\www\wpblog ZIP file and placed it into my local wamp\www\ to make it an active app under the WAMP server.
  12. Restarted all the services on the WAMP server. Its icon turned green in the System Tray. (If it's yellow/orange, there's more than likely a port conflict.)
Now clicking the wpblog app on my WAMP server's home page brought the WordPress blog up with no issues. All the articles were there too. A successful migration!

Note that you don't need the entire WAMP server folder (which can be huge -- a GB or more). You just need the blog folder under the WAMP server's WWW directory. In this case, we didn't know so we copied the whole thing!

In addition to the above steps, you can use a migration plugin such as Duplicator to successfully move a WordPress blog, data and all, from one Windows machine to another. Additional help for the plugin can be found here. In our case, we didn't know about the plugin, so we used a more brute-force technique!