WampServer从2.5升级至3.1.3的关键注意事项及解决方案咨询
Hey there, let's break down your WampServer 2.5 to 3.1.3 upgrade step by step, focusing on the key components you're concerned about, plus a solid game plan to avoid headaches:
The biggest gotcha you've already identified is the '0000-00-00' date value restriction—MySQL 5.7 enables strict SQL mode by default, which blocks invalid dates like this. Here's how to fix it properly:
Temporary workaround (not recommended long-term):
Edit yourmy.ini/my.cnffile and adjust thesql_modeto excludeNO_ZERO_DATEandNO_ZERO_IN_DATE. For example:sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONThis lets your existing code/database work temporarily while you fix the root issue.
Permanent fix (best practice):
- Backup your database first—always do this before mass updates.
- Batch-update all '0000-00-00' values to a valid default (like
NULLor '1970-01-01') using SQL:
Repeat this for every table/column using invalid dates.UPDATE your_table SET date_column = '1970-01-01' WHERE date_column = '0000-00-00'; - Update your PHP code to stop inserting '0000-00-00'—use
NULLor a valid default date instead when no date is available.
Other MySQL 5.7 changes to watch for:
- The
PASSWORD()function is deprecated; useSHA2()instead if you're handling password hashing directly in SQL. - Default authentication plugin changed to
caching_sha2_password, but WampServer usually sticks withmysql_native_passwordfor compatibility with older PHP versions. If you get connection errors, verify your MySQL user usesmysql_native_password.
The most critical change here is the full deprecation of the old mysql_* function family (like mysql_connect(), mysql_query()). These functions were already warned against in 5.5, but 5.6 marks them as officially deprecated—and they'll be removed in later versions. You must migrate to either:
mysqli_*functions (improved MySQL extension, supports prepared statements)- PDO (PHP Data Objects, more flexible for multiple databases)
Other notable changes:
always_populate_raw_post_datadefaults to-1in 5.6. If your code relied on this being0, you'll need to adjust your php.ini or update code that reads raw POST data.- Timezone warnings: PHP 5.6 will throw warnings if
date.timezoneisn't set in php.ini. Adddate.timezone = Asia/Shanghai(or your local timezone) to fix this. - E_STRICT errors are now included in E_ALL. You might see new warnings about code that doesn't meet strict standards—fix these to avoid future issues.
Since both are Apache 2.4.x versions, most core configs are compatible—but don't just copy your old httpd.conf directly. Here's why:
- Newer Apache versions include updated default modules (like
mod_http2for HTTP/2 support) and security hardening that you'll miss if you overwrite the new config. - Permission syntax changes: While Apache 2.4 still supports the old
Order allow,denyandAllow from all, it's better to migrate to the modernRequire all grantedsyntax for long-term compatibility. - Virtual host and custom rules: Instead of replacing the new
httpd.conf, copy your custom virtual hosts, rewrite rules, and module load directives into the new file (or include them viaIncludedirectives for cleaner organization).
To minimize downtime and avoid critical issues, follow this step-by-step plan:
Full Backup First
- Backup your entire
wwwdirectory (all website files) - Export all MySQL databases using
mysqldump(or copy thedatafolder after stopping MySQL) - Save copies of your old
httpd.conf,php.ini, andmy.ini
- Backup your entire
Test in a Staging Environment
- Set up a duplicate of your production environment (same OS, same site/data)
- Install WampServer 3.1.3 there, migrate your files/databases, and test every feature (user login, data submission, queries, etc.)
- Fix any issues here before touching production.
Fix Critical Issues Pre-Upgrade
- Address the MySQL '0000-00-00' problem in your staging database/code first
- Migrate all
mysql_*code tomysqlior PDO in staging
Migrate Configs Carefully
- Compare your old
httpd.confwith the new one, and only copy over your custom settings (virtual hosts, rewrite rules, module loads) - Update permission syntax to use
Requireinstead ofOrder/Allowwhere possible
- Compare your old
Debug with Logs
- Enable Apache's
error.log, PHP'sphp_error.log, and MySQL'serror.log - If something breaks, check these logs first—they'll tell you exactly where the issue is.
- Enable Apache's
Production Upgrade
- Stop your old WampServer service
- Re-backup production data (just to be safe)
- Install WampServer 3.1.3, migrate your files/databases/configs
- Start the services and run a full round of tests to confirm everything works.
内容的提问来源于stack exchange,提问作者ducky

