Troubleshooting Duplicator: Fixing wp-config.php Password Errors with Special Characters
Content
Users of the Duplicator plugin have reported a recurring issue where a WordPress site fails after a migration, often showing a database connection error or a syntax error in the wp-config.php file. This problem is frequently traced back to how the plugin handles database passwords that contain special characters.
The Problem: Special Characters Causing Errors
When Duplicator's installer runs, it generates a new wp-config.php file. If your database password contains certain special characters—such as $, {, }, > (>), or the pound sterling symbol £ (£)—they may not be escaped or handled correctly. This can result in two main types of errors:
- PHP Syntax Errors: Characters like
$and{have special meaning in PHP. If they are not properly escaped within the password string, PHP will try to interpret them as code, causing a fatal error like:
unexpected ‘(‘, expecting variable (T_VARIABLE) or ‘{‘ or ‘$’ in /wp-config.php on line XX - Incorrect Character Encoding: The installer might convert special characters into their HTML entity equivalents. For example, a password like
testing1£££££2111might be written to the config file as:
define( 'DB_PASSWORD', "testing1u00a3u00a3u00a3u00a3u00a32111" );
This encoded version is not the same as the original password and will cause the database connection to fail.
Why This Happens
This appears to be a bug related to specific versions of Duplicator (e.g., version 1.3.10 was frequently mentioned in reports). The function that writes the password value to the wp-config.php file did not always properly escape or format strings containing these problematic characters. The issue was often fixed in subsequent developer or stable releases.
How to Fix It
If you encounter a database connection error immediately after a Duplicator migration, follow these steps to resolve the password issue.
Solution 1: Manually Edit wp-config.php (Quick Fix)
The fastest solution is to directly edit the wp-config.php file on your server.
- Access your website's root directory via FTP, SFTP, or your hosting provider's file manager.
- Locate and open the
wp-config.phpfile for editing. - Find the line that defines the database password. It will look like this:
define( 'DB_PASSWORD', 'your_password' ); - Check the password value. If it contains HTML entities (like
>oru00a3) or if the quotes are double ("") and your password has special characters, you need to correct it.- Replace any HTML entities with their actual character (e.g., change
>back to>). - Ensure the password is wrapped in single quotes (
' '), as this can prevent PHP from interpreting special characters within the string. For example:
define( 'DB_PASSWORD', 'Mi)8J0={$(cH' );
- Replace any HTML entities with their actual character (e.g., change
- Save the file and upload it back to your server, overwriting the old one.
- Try to access your WordPress site or login again. The error should now be resolved.
Solution 2: Use a Simpler Password for Migration
If you frequently run into this problem, a reliable workaround is to temporarily change your database password to one that only contains alphanumeric characters (letters and numbers) before creating the Duplicator package. After the migration is complete, you can change the password back to your preferred, more complex one directly in the database and then update the wp-config.php file manually.
Solution 3: Check for a Plugin Update
This specific issue with special characters was acknowledged and addressed by the Duplicator team in updates following version 1.3.10. If you are using an older version, updating to the latest release of the plugin may permanently resolve the problem. Always ensure you are using the most recent stable version for the best experience.
Conclusion
Errors related to special characters in database passwords can be a frustrating hurdle during migration, but they are usually simple to fix. Manually editing the wp-config.php file to ensure the password is correctly formatted is the most direct solution. For ongoing use, keeping Duplicator updated is the best way to avoid such bugs.
Related Support Threads Support
-
Password Char Pass-through issuehttps://wordpress.org/support/topic/password-char-pass-through-issue/
-
Latest version is breaking passwordshttps://wordpress.org/support/topic/latest-version-is-breaking-passwords/
-
No feedback for wrong characters db passwordhttps://wordpress.org/support/topic/no-feedback-for-wrong-characters-db-password/
-
wp-config.php uses ” instead of ‘ for the passwordhttps://wordpress.org/support/topic/wp-config-php-uses-instead-of-for-the-password/
-
Stuck in the wp-amin login page ,even after entering the correct Uname and passhttps://wordpress.org/support/topic/stuck-in-the-wp-amin-login-page-even-after-entering-the-correct-uname-and-pass/
-
Change *_SALT and *_KEY defines in wp_config when cloning to new URLhttps://wordpress.org/support/topic/change-_salt-and-_key-defines-in-wp_config-when-cloning-to-new-url/
-
Not Handling Greater Than Characters in Passwords Correctlyhttps://wordpress.org/support/topic/not-handling-greater-than-characters-in-passwords-correctly/
-
Install Step 3 of 4 annoying user/pass chrome populationhttps://wordpress.org/support/topic/install-step-3-of-4-annoying-user-pass-chrome-population/