Get the Best WordPress Backup
& Migration Plugin Today
Get Duplicator Now

Duplicator Documentation

Documentation, Reference Materials, and Tutorials for Duplicator

How to fix database connection issues

Having trouble connecting to your database during installation? This guide covers common database connection issues and provides step-by-step solutions to fix them.

Issue A: Validation Fails

On Step 1 (Pro) and Step 2 (Lite) of the installer, when you click “Test Database,” you receive a fail status.

Solution 1: Validation Checklist

Ensure that the database credentials and permissions are correctly set up:

  • Double-check that the database and database user have been created.
  • Verify that the password matches the database user being used.
  • Ensure the database user is assigned to the database with the correct permissions.
  • Temporarily change the database user password to ‘test123’ to validate character input.
  • Contact your hosting provider for the exact required parameters.

Solution 2: Hostname Validation

The default hostname ‘localhost’ works in most cases, but it may differ based on the hosting provider. Confirm the exact settings with your host. Some common variations include:

  • mysql.yourname.com
  • mysql.hostingcompany.com
  • mysql.hostingcompany.com:1400

If you see an error like “Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2),” it is likely due to an incorrect hostname.

Quick Fix:

Contact your hosting provider to confirm the correct credentials for database connections. Refer to these support resources:

  • GoDaddy
  • HostMonster
  • Bluehost
  • HostGator
  • DreamHost
  • Search Google: "[Your host] database setup"

Solution 3: SQL Mode Conflicts

If you encounter an “Error reading database variables” message, your MySQL instance may have “ANSI_QUOTES” enabled in its SQL mode. Since MySQL treats double quotes as identifiers instead of strings in this mode, it can cause issues. To resolve this, remove the ANSI_QUOTES SQL mode.

Common Error Messages:

  • Unknown column ‘wp_table’ in ‘where clause’

Issue B: Access Denied

If you receive an error such as Access denied for user 'myuser'@'localhost' (using password: YES) when testing the database connection, follow these solutions.

Common Error Messages:

  • Error: 'Access denied; you need (at least one of) the PROCESS privilege ...
  • The database user for this WordPress site does NOT have sufficient permissions to write stored procedures ...

Solution 1: Assigning Full Privileges

Ensure that the database user is assigned to the database with full privileges:

  • The easiest way to confirm permissions is to contact your hosting provider.
  • Follow the WordPress Codex Guide to create a Database and User.
  • For a cPanel demo, refer to this article.
  • For MySQL 8+: Run the following command to grant all required privileges: GRANT SHOW_ROUTINE ON *.* TO <USER>@<LOCATION>;

Solution 2: Creating a New Database User

If assigning full privileges does not work, create a new database user, grant full permissions, and assign it to the database. This can resolve caching issues stored in the database.

Solution 3: Moving Databases Between Servers

When migrating a site between MySQL servers, different MySQL versions may not support the same directives, leading to an error such as:

  • mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege ...'

Workarounds:

  • Build in PHP Mode: Use PHP to avoid MySQL directive conflicts.
  • Modify SQL Script: Remove unsupported directives from the SQL file before running the installer.

Issue C: Database Timeouts

If SQL connection timeouts or memory errors occur on Step 2, follow these solutions.

Solution 1: Enable Database Chunking

This multi-thread process splits the database installation into smaller queries.

  1. Run the installer and activate the Advanced mode by clicking the button “Advanced
  2. In Step 1 Under Options » Database Tab » Processing, enable “Chunking Mode.”
  3. Continue with the installation.

Solution 2: Skip Database Extraction

Instead of creating new database tables, manually import the database.

Steps:

  1. Extract database.sql from the archive.
  2. Use phpMyAdmin to remove existing tables and import the SQL file.
  3. In the installer, select “Skip Database Extraction” under Advanced Options.

Solution 3: Duplicator Lite-Specific Issues

Duplicator Lite (v1.4.7.2 or earlier) supports only a single-threaded database import, which can cause issues on busy shared servers.

Workarounds:

  • Run the installer during off-peak hours.
  • Change the Build Mode in Duplicator settings to “PHP.”
  • Contact your host to increase server timeout limits.
  • Upgrade to Duplicator Pro to use SQL file chunking.

Common Error Messages:

  • MySQL Server has gone away, out of memory, or 500 Error

Troubleshooting

If connection issues persist, use PHP code to isolate the problem. Create a file called db-test.php in the same directory as the installer and insert the following code:

<?php
$servername = "your_server";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Success: Connected to MySQL!";
?>

If the script fails, share it with your hosting provider for further debugging.

This script is also available in the Duplicator Pro tools directory at /plugins/duplicator-pro/tools/db-test.php.

By following these solutions, you can resolve database connection issues and ensure a smooth installation process.

Was this article helpful?

Related Articles