I almost blew it today! If you are familiar with WordPress you may already know what happens when you type the wrong URL info into the General Settings. That’s right, your entire WordPress website is completely unreachable. Well, I did just that late afternoon yesterday. All of a sudden all of the work I put into this WordPress project over the past 6 weeks was completely hosed, and I didn’t have a clue how to fix it.
Talk about nerve wracking. This is probably the worst jam I’ve gotten into.
Saturday evening I decided to register the “www.k6hr.com” domain name. It was so inexpensive at $24 I couldn’t resist. This included Dynamic DNS service. In my haste, I misconfigured the site URL’s in the WordPress SQL database. I also made some assumptions that almost wrecked the entire webserver configuration. At one point the server stopped working!
My first mistake was thinking all I had to do was change the name of my server to ‘k6hr.com’ and run the ‘homing beacon’ and I would be good to go. Big mistake. It took me hours to figure out it wouldn’t work that way. Of course, now I would have to undo everything I changed. I kept a note pad next to me and wrote down every command and edit I had performed. A changelog so to speak, so I could successfully undo it in the event of further disaster.
Database Edit Breakthrough
After several more hours of research (leading into today) and more trial and error, I found out that editing the SQL database was the only way to fix this mess. Hours of searching brought me here, and I was able to locate, backup, edit, and restore the database. Unbelievable! It looked like I could fix it. After all, to the best of my knowledge, so far I had only damaged the SQL database file, all my content etc. was completely intact. I had to learn database editing right now if I was going to be able to fix this thing.
When you don’t know exactly what you’re doing make a backup!
I created a backup file:
sudo mysqldump -p db_filename > /backup/db_filename.sql
Then I opened the backup file (as root) using the Midnight Commander file browser, (I’d be lost without “mc”) and did a search for “k6hr.com” and found the two entries I needed to change. I typed in the corrected URL info, saved the backup file, and then replaced my hosed WP database with the edited version of the backup and crossed my fingers.
sudo mysql -u <user> -p < /backup/db_filename.sql
I restarted mysqld, then attempted to load the WP admin page from my original working ampr.org domain webserver…
It worked! What a relief!
I had successfully recovered the database after working some 14+ hours. I could now login to my WP website again! But, there was another problem, no other WP webpages would load. Only the admin page would open. I was off to a great start either way, as I had no access whatsoever a minute ago.
It turned out the first thing I changed yesterday was the last thing that needed to be reset today. It was the “homing beacon”. I noticed when trying to connect to WP pages using my original working hostname, which I just got done restoring, were timing out with an error message saying “k6hr.com” was unreachable. The URL was being redirected from gw.k6hr.ampr.org to k6hr.com and of course this could never work.
A Working Solution
I figured out that I had to uninstall the homing beacon, and delete all the DNS records it had created. On the ChangeIP.com website I found the DNS Manager and deleted everything. That was it! This WordPress website had been successfully recovered. Good thing, because I was sick over the idea of losing it to such a bonehead mistake.
Brian N1URO advised me on several aspects of getting this working:
- Add DNS A and CNAME records pointing to my server IP address
- Eliminate use of the Secondary HTTP port 8080
- Add a Virtual Host to the Apache2 configuration
Updates and/or additions to DNS records can take up to 24 hours to propagate through all the nameservers on the web. So possibly by 10pm tomorrow night “www.k6hr.com” will be alive and well on the web!