{"record":{"id":"5dab7216e18eb769","repo":"phpmyadmin/phpmyadmin","slug":"1045-error-access-denied-for-user-additional-error","errorCode":"1045","errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"ConnectionException","httpStatus":null,"severity":"error","filePath":"src/Dbal/DbiMysqli.php","lineNumber":113,"sourceCode":"                $server->user,\n                $server->password,\n                '',\n                (int) $server->port,\n                $server->socket,\n                $clientFlags,\n            );\n        } catch (mysqli_sql_exception $exception) {\n            $errorNumber = $exception->getCode();\n            $errorMessage = $exception->getMessage();\n\n            if (! $server->ssl && $this->isSslRequiredByServer($errorNumber, $errorMessage)) {\n                return self::connect($server->withSSL(true));\n            }\n\n            mysqli_report(MYSQLI_REPORT_OFF);\n\n            if ($errorNumber === 1045 && $server->hideConnectionErrors) {\n                throw new ConnectionException(\n                    sprintf(\n                        __(\n                            'Error 1045: Access denied for user. Additional error information'\n                            . ' may be available, but is being hidden by the %s configuration directive.',\n                        ),\n                        '[code][doc@cfg_Servers_hide_connection_errors]'\n                        . '$cfg[\\'Servers\\'][$i][\\'hide_connection_errors\\'][/doc][/code]',\n                    ),\n                    $errorNumber,\n                    $exception,\n                );\n            }\n\n            throw new ConnectionException($errorNumber . ': ' . $errorMessage, $errorNumber, $exception);\n        }\n\n        $mysqli->options(MYSQLI_OPT_LOCAL_INFILE, (int) defined('PMA_ENABLE_LDI'));\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/phpmyadmin/phpmyadmin/blob/70d713dc39f5f7e0683c0ee38ab816b7e72b6a49/src/Dbal/DbiMysqli.php#L95-L131","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// config.inc.php (diagnostics only — do not leave in production)\n// before\n$cfg['Servers'][$i]['hide_connection_errors'] = true;\n// after\n$cfg['Servers'][$i]['hide_connection_errors'] = false; // reveal full 1045 detail while debugging","handlingStrategy":"try-catch","validationCode":"// pre-flight credentials check outside phpMyAdmin\n$ok = @mysqli_real_connect(mysqli_init(), $host, $user, $pass, null, $port);\nif (!$ok && mysqli_connect_errno() === 1045) { /* fix credentials first */ }","typeGuard":"// detect the hidden-credentials case by error code\n$code = $e instanceof ConnectionException ? $e->getCode() : 0;\n$isAccessDenied = ($code === 1045);","tryCatchPattern":"try {\n    $dbi->connect($server);\n} catch (ConnectionException $e) {\n    if ($e->getCode() === 1045) {\n        // credentials rejected; message may be masked by hide_connection_errors\n        throw new RuntimeException('MySQL login failed: verify user/password/host', 0, $e);\n    }\n    throw $e;\n}","preventionTips":["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)."],"tags":["mysql","authentication","access-denied","mysqli"],"backgroundTag":"authentication-required","analyzedSha":"70d713dc39f5f7e0683c0ee38ab816b7e72b6a49","analyzedAt":"2026-09-13T19:13:03.620Z","contentChangedAt":"2026-09-13T19:13:03.620Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}