I got my new 64-bit web server up and running today. Now the main task that remains is to get my data moved over to it. I talked myself into going with an Apache setup, since one program I want to run (Webtrees) is designed for Apache and its search engine optimization seems to work better under Apache than Nginx. It’s fast anyway; displaying the 17-person family of Andrew Davis McQueen of Leesville, Mo., briefly consumes 2% of the available CPU time in Webtrees with the APC PHP cache installed and enabled. And that should get better, seeing as newer, faster, better versions of both Apache and PHP were released in the last month.
As I built my new 64-bit web server, I messed up MySQL a couple of times. When you break MySQL beyond repair, here’s how to start over with a fresh MySQL install and a fresh /var/lib/mysql without doing a Windows-like reformat and reinstall of the entire operating system:
apt-get remove --purge mysql-server*
Note the asterisk.
Then, reinstall with the command you’re all too familiar with:
apt-get install mysql-server
And when you do, you’ll get a fresh copy, including the prompt to enter a MySQL root password. And hopefully whatever cruft was tripping MySQL up will be gone.
This works in Debian Squeeze; presumably it works in Ubuntu as well.
And yes, I agree it’s a bit of a cop-out to start over rather than fixing what’s broken, and fixing a busted MySQL installation is good practice for a DBA. But sometimes, if you’re not very far along, it’s the faster option. Blowing away MySQL and installing a fresh copy takes a few minutes, at most.
I learned one other thing when I was building the server. Restart Apache early and often. Memorize this command:
If you do anything more complicated than changing a directory, you’ll probably need to restart Apache. I have a sneaking suspicion that the main reason I struggled to get Nginx running with PHP and MySQL was because the tutorials missed a few Nginx restarts along the way. If you’re having trouble getting PHP to talk with MySQL and can’t think of anything else to try, restart the web server.
I also know now that trying to move my databases straight over from my old server to my new server got me into trouble. I’m pretty sure I used to be able to get away with doing that, but trying that this time kept breaking MySQL. Exporting the data from the old server and importing it on the new one is a safer approach.
David Farquhar is a computer security professional, entrepreneur, and author. He started his career as a part-time computer technician in 1994, worked his way up to system administrator by 1997, and has specialized in vulnerability management since 2013. He invests in real estate on the side and his hobbies include O gauge trains, baseball cards, and retro computers and video games. A University of Missouri graduate, he holds CISSP and Security+ certifications. He lives in St. Louis with his family.