phpmyadmin/phpmyadmin · error · ConnectionException
1045
1045
Error message
Error 1045: Access denied for user. Additional error information may be available, but is being hidden by the $cfg['Servers'][$i]['hide_connection_errors'] configuration directive.
What it means
A ConnectionException raised in DbiMysqli::connect() specifically for MySQL error 1045 (access denied) when $cfg['Servers'][$i]['hide_connection_errors'] is enabled. Instead of forwarding the server's detailed denial message (which may leak the hostname/user), phpMyAdmin throws a generic localized message pointing at the hide_connection_errors directive. The 1045 code is preserved so callers can still detect an authentication failure.
Solutions
- Verify credentials in $cfg['Servers'][$i]['user']/'password' are correct by testing with the mysql CLI.
- Temporarily set $cfg['Servers'][$i]['hide_connection_errors'] = false to see the underlying server message, then re-enable it.
- Check the MySQL user's host pattern (SELECT user,host FROM mysql.user) matches the connecting host.
- If using MySQL 8+, confirm the client library supports the account's authentication plugin (e.g. caching_sha2_password) or change the plugin.
Example fix
// config.inc.php (diagnostics only — do not leave in production) // before $cfg['Servers'][$i]['hide_connection_errors'] = true; // after $cfg['Servers'][$i]['hide_connection_errors'] = false; // reveal full 1045 detail while debugging
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight credentials check outside phpMyAdmin
$ok = @mysqli_real_connect(mysqli_init(), $host, $user, $pass, null, $port);
if (!$ok && mysqli_connect_errno() === 1045) { /* fix credentials first */ } Type guard
// detect the hidden-credentials case by error code $code = $e instanceof ConnectionException ? $e->getCode() : 0; $isAccessDenied = ($code === 1045);
Try / catch
try {
$dbi->connect($server);
} catch (ConnectionException $e) {
if ($e->getCode() === 1045) {
// credentials rejected; message may be masked by hide_connection_errors
throw new RuntimeException('MySQL login failed: verify user/password/host', 0, $e);
}
throw $e;
} Prevention
- Validate credentials with the mysql CLI before changing phpMyAdmin config.
- Check that the MySQL account's host pattern matches the web server's source host.
- Keep hide_connection_errors true in production but know it masks 1045 detail — test credentials directly instead.
- For MySQL 8 servers, confirm client library/plugin compatibility (caching_sha2_password, sha256_password).
When it happens
Trigger: Calling DbiMysqli::connect() (directly or via the parent connect()) against a MySQL/MariaDB server that rejects the credentials with error 1045 while the config flag hideConnectionErrors is true for that server index.
Common situations: Wrong username/password in config.inc.php; user exists only on a different host pattern (e.g. 'user'@'localhost' vs '%'); auth plugin mismatch (caching_sha2_password vs old clients); hosting panels enabling hide_connection_errors for security, hiding the true reason from the admin.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Dynamic message: $errorNumber . ': ' . $errorMessage…
- UpdateAuthPluginFailure wrapping Generator::mysqlDie output…
- Account locking is not supported.
- DatabasesFullInfoFailure wrapping Generator::mysqlDie HTML…
- Error reading data for table
AI-assisted analysis of phpmyadmin/phpmyadmin@70d713dc39 (2026-09-13).
Data as JSON: /api/errors/5dab7216e18eb769.
Report an issue: GitHub.
Appendix: source
Thrown at src/Dbal/DbiMysqli.php:113
$server->user,
$server->password,
'',
(int) $server->port,
$server->socket,
$clientFlags,
);
} catch (mysqli_sql_exception $exception) {
$errorNumber = $exception->getCode();
$errorMessage = $exception->getMessage();
if (! $server->ssl && $this->isSslRequiredByServer($errorNumber, $errorMessage)) {
return self::connect($server->withSSL(true));
}
mysqli_report(MYSQLI_REPORT_OFF);
if ($errorNumber === 1045 && $server->hideConnectionErrors) {
throw new ConnectionException(
sprintf(
__(
'Error 1045: Access denied for user. Additional error information'
. ' may be available, but is being hidden by the %s configuration directive.',
),
'[code][doc@cfg_Servers_hide_connection_errors]'
. '$cfg[\'Servers\'][$i][\'hide_connection_errors\'][/doc][/code]',
),
$errorNumber,
$exception,
);
}
throw new ConnectionException($errorNumber . ': ' . $errorMessage, $errorNumber, $exception);
}
$mysqli->options(MYSQLI_OPT_LOCAL_INFILE, (int) defined('PMA_ENABLE_LDI'));
View on GitHub (pinned to 70d713dc39)