Disclaimer: Always have a backup of your c:\wamp folder before you attempt any of the following advice. Use the following information at your own risk.
Desperate and want to cut to the chase? if your WAMP is not working for some reason, just uninstall it via the Add/Remove programs utility and then re-install it.
Okay, here's the longer explanation:
Like most every other web developer, I use local installs of Apache, MySQL, and PHP to develop websites on my personal computer before I upload the finished site to the web server. Back in the day, we used to install each of the aforementioned separately and then configure them to run together; a process that could take an entire day.
Then, one day, several years ago, someone came up with the brilliant idea to package the holy trinity of web development utilites together into one package that could be installed with a single click. The package for Windows PCs is called WAMP (Windows Apache Mysql PHP). For Mac computers it is called MAMP, and there's another flavour called XAMPP that also adds Perl to the mix. All the packages include extra utilities like PhpMyAdmin to make database management a breeze.
If you've been developing websites for more than a week, you'll know that your local web development environment is your lifeblood, so if you screw up the operation of it, it's a bit like having your still-beating heart ripped out of your chest. Overly dramatic, you say? I think not. I have over 1 GB of MySQL data in 121 databases. Yes, I have backups, but re-installs from backups are always a pain especially if you aren't doing weekly DVD backups ... remote backups are great, but can take several hours to download all those individual files and reinstall. And, as is the rule in these things, it's not the stuff you had backed up a week or a month ago on DVD that you actually want ... you want the stuff you were working on today and now your WAMP is spitting errors and Apache won't start.
I had my WAMP (running on WinXP Pro) chuck a wobbly last night after I attempted to add PHP 5.3.0 to the list of version choices. Immediately after the install, WAMP couldn't find my extensions directory, and yet the path was correct. Then it started writing corrupt gibberish to the wampmanager.ini file, and then it couldn't find even the php.ini config file. I spent 4 hours hunting down errors, editing .ini and .conf files, downloading new dll files, renaming dll files, and nothing worked.
I wanted to just re-install WAMP, but I was afraid I'd lose all my databases and data if I uninstalled it. I did fifty Google searches looking for advice if it was okay to just re-install WAMP and not lose the DB data, but couldn't find anything definitive. All the advice I found was focussed on finding and repairing the individual errors. Finally, at 1:37 am, I found a mention in a backwater forum that it was okay to just un-install WAMP and that the data directories would be left intact.
What follows is the procedure I used:
NOTE: Do not remove your c:\wamp directory during this procedure. Always leave it in place, just create the backup as described below.
Create Backup: I backed up my c:\wamp directory to a new folder, a process that took nearly 2 hours!
Re-install WAMP: Once the backup was safely tucked away to the side, I first tried to simply re-install WAMP on top of the existing install. This actually fixed 99% of the errors, but Apache was still crashing because of the PHP Loadmodule line in the .conf file.
Uninstall WAMP via Windows Control Panel: I then used the Windows Add/Remove programs utility to uninstall WAMP. Then I reinstalled WAMP. Then, holding my breath, I started WAMP.
WAMP started with no errors and all my MySQL databases and data were still intact. Huzzah!
Re-set the MySQL root password:
Because of the fresh WAMP install, you do lose your MySQL root password, so you need to re-set it so your websites that use MySQL can connect and display your web page data.
This can often be a hassle because as soon as you re-set the root password for localhost and 127.0.0.1 via PhpMyAdmin's GUI, you get locked out and can't see your list of databases. Here's what you do to fix that:
Note: Make sure you use the same password for root you had before or you'll have to edit the MySQL connection info on all your existing websites! If you can't remember the password (but you should since you setup new databases all the time), it is in PhpMyAdmin's config.inc.php file. Check the back-up you made before starting this whole procedure (you made a backup, right?).
- Start your newly re-installed WampServer,
- Go to http://127.0.0.1 or http://localhost,
- Click on the PhpMyAdmin link on your WAMP homepage,
- Click the privileges link in the main content window,
- Add your root password back into the 127.0.0.1 and localhost by clicking the edit icon for each of these hosts,
- Click the little house icon in the left nav column of PhpMyAdmin ... you'll now be locked out,
- Using a plain text editor like Notepad or Notepad ++, open C:\wamp\apps\phpmyadminX.x.x\config.inc.php and find $cfg['Servers'][$i]['user'] and the line below it, $cfg['Servers'][$i]['password'],
- Make the value for $cfg['Servers'][$i]['user'] whatever you had before, mine was root and it was already there,
- Make the value of $cfg['Servers'][$i]['password'] your current / old password,
- Save the file and re-start all services using the WAMP tray icon.
Provided all the above went well, you will be able to access all your MySQL databases again via PhpMyAdmin.
From start to finish, it should only take 5 to 10 minutes at most to fix a broken WAMP ... not 5 hours or more!