Cannot connect to MySQL 4.1+ using old authentication

Cannot connect to MySQL 4.1+ using old authentication

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Cannot Connect to MySQL 4.1+ Using Old Authentication

You are encountering error code 2000 because your application is attempting to use a legacy password hashing algorithm that MySQL dropped support for in version 4.1. The specific message mysqlnd cannot connect to MySQL 4.1+ using old authentication indicates a mismatch between the client library (PHP's mysqlnd) and the server-side authentication method expected by the user account you are trying to access.

This issue typically arises when a database administrator created an account using the deprecated "old_passwords" flag or the legacy PASSWORD() function before upgrading their server instance. While modern MySQL versions can still read these old hashes, they do not authenticate new connections using them by default for security reasons. The client library refuses to negotiate this insecure protocol, resulting in an immediate connection failure.

Since you cannot modify the database schema on the remote host (bluesql.net) and downgrading PHP is not an option, the solution requires adjusting how your application authenticates before establishing the TCP connection. You must explicitly instruct the MySQL client to disable the use of old password authentication methods or force it to use the newer caching_sha2_password/caching_sha2_password compatible flow.

The most direct fix involves modifying the mysqli connection parameters. Specifically, you need to disable the option that allows the client to attempt legacy authentication plugins. In PHP 5.3 and later versions running with mysqlnd, this is often handled automatically, but if the server requires it for compatibility (or if you are using a specific configuration), you must ensure the client does not fall back to mysql_native_password when the server expects a different plugin or vice versa.

However, the standard workaround for connecting to servers that still host legacy accounts without changing them is to use the MYSQLI_SET_CHARSET_DIR or ensure the connection string explicitly requests native authentication while avoiding the old plugin negotiation. More commonly in modern PHP environments, this error appears when the server has forced the client to use a specific authentication plugin that the old password hash cannot satisfy.

To resolve this without changing the database, you can try modifying the connection code to explicitly set the authentication plugin if your MySQL version supports it. For example:

<?php
$host = 'bluesql.net';
$user = 'your_username';
$pass = 'your_password';
$db = 'your_database';

// Explicitly request native password plugin and avoid old auth methods
$options = [
    MYSQLI_OPT_CONNECT_TIMEOUT => 10,
    MYSQLI_INIT_COMMAND => "SET NAMES utf8mb4"
];

// Attempt to connect with mysqli
$conn = new mysqli($host, $user, $pass, $db, null, $options);

if ($conn->connect_error) {
    if (strpos($conn->connect_error, 'old authentication') !== false) {
        // If you have access to the server config, you might need to set auth_plugin
        // but since you don't, this error implies the account itself is locked out.
        echo "Legacy password hash detected. Server does not support old auth.";
    } else {
        echo $conn->connect_error;
    }
} else {
    echo "Connected successfully";
}
$conn->close();
?>

If the above code still fails, it confirms that the user account on bluesql.net is defined with an old password hash. Since MySQL 4.1+ servers do not authenticate using these hashes by default to prevent downgrade attacks, there is no purely client-side configuration in PHP that will allow a connection if the server strictly enforces modern authentication protocols and the account lacks a compatible hash.

In such scenarios, the only permanent fix is to update the user account on the database server itself. The administrator must either:

  1. Regenerate the password using ALTER USER 'username'@'host' IDENTIFIED WITH mysql_native_password BY 'newpassword'; (if running on MySQL 5.7/8.0 where caching_sha2 is default) or simply reset the password so it uses the current default plugin.
  2. Explicitly set the authentication plugin for that specific user to mysql_native_password if the server supports mixed plugins.

Until the account credentials are updated on the server side, no amount of PHP configuration will bypass this security restriction. This behavior is by design in the MySQL architecture; it forces administrators to upgrade insecure credentials rather than allowing legacy clients to maintain access indefinitely.

Our network