{"id":"61e17940aa6a4d82","repo":"go-sql-driver/mysql","slug":"this-user-requires-clear-text-authentication-if-y","errorCode":null,"errorMessage":"this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN","messagePattern":"this user requires clear text authentication\\. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":23,"sourceCode":"// This Source Code Form is subject to the terms of the Mozilla Public\n// License, v. 2.0. If a copy of the MPL was not distributed with this file,\n// You can obtain one at http://mozilla.org/MPL/2.0/.\n\npackage mysql\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\n// Various errors the driver might return. Can change between driver versions.\nvar (\n\tErrInvalidConn       = errors.New(\"invalid connection\")\n\tErrMalformPkt        = errors.New(\"malformed packet\")\n\tErrNoTLS             = errors.New(\"TLS requested but server does not support TLS\")\n\tErrCleartextPassword = errors.New(\"this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN\")\n\tErrNativePassword    = errors.New(\"this user requires mysql native password authentication\")\n\tErrOldPassword       = errors.New(\"this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords\")\n\tErrUnknownPlugin     = errors.New(\"this authentication plugin is not supported\")\n\tErrOldProtocol       = errors.New(\"MySQL server does not support required protocol 41+\")\n\tErrPktSync           = errors.New(\"commands out of sync. You can't run this command now\")\n\tErrPktSyncMul        = errors.New(\"commands out of sync. Did you run multiple statements at once?\")\n\tErrPktTooLarge       = errors.New(\"packet for query is too large. Try adjusting the `Config.MaxAllowedPacket`\")\n\tErrBusyBuffer        = errors.New(\"busy buffer\")\n\n\t// errBadConnNoWrite is used for connection errors where nothing was sent to the database yet.\n\t// If this happens first in a function starting a database interaction, it should be replaced by driver.ErrBadConn\n\t// to trigger a resend. Use mc.markBadConn(err) to do this.\n\t// See https://github.com/go-sql-driver/mysql/pull/302\n\terrBadConnNoWrite = errors.New(\"bad connection\")\n)\n\nvar defaultLogger = Logger(log.New(os.Stderr, \"[mysql] \", log.Ldate|log.Ltime))\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/c426bd93799de0f0e094c8f0582872c529d0ed0a/errors.go#L5-L41","documentation":"ErrCleartextPassword is returned by the auth handshake (auth.go:298) when the server requests the `mysql_clear_password` plugin (used by PAM / LDAP authentication) and the DSN does not set allowCleartextPasswords=1. The driver blocks it by default because the plugin transmits the password in cleartext over the network, which is unsafe without an encrypted transport.","triggerScenarios":"The MySQL user account is configured with mysql_clear_password (or the server forces it via auth switch). The driver's auth() switch at auth.go:296 sees plugin==\"mysql_clear_password\" but mc.cfg.AllowCleartextPasswords is false, so it returns ErrCleartextPassword.","commonSituations":"Connecting to a MySQL/Aurora/RDS account backed by PAM or LDAP; enterprise SSO setups; accounts created with `IDENTIFIED WITH mysql_clear_password`.","solutions":["Add `allowCleartextPasswords=1` to the DSN AND ensure the transport is encrypted (tls=true or a tunnel) so the password is not exposed on the wire.","If possible, switch the account to a hashing plugin (caching_sha2_password / mysql_native_password) so cleartext transmission is unnecessary.","Confirm the password is correct; this error is about the plugin, not a wrong password."],"exampleFix":"// before\ndsn := \"u:p@tcp(host:3306)/db\"\n// after\ndsn := \"u:p@tcp(host:3306)/db?tls=true&allowCleartextPasswords=1\"","handlingStrategy":"validation","validationCode":"if usesCleartextPlugin {\n    if !tlsEnabled {\n        return errors.New(\"refusing cleartext password without TLS\")\n    }\n    dsn += \"&allowCleartextPasswords=1\"\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, mysql.ErrCleartextPassword) {\n    // add allowCleartextPasswords=1 (with TLS) and retry, or surface to user\n}","preventionTips":["Always pair allowCleartextPasswords=1 with tls=true.","Prefer hashing plugins for new accounts.","Document the account's auth plugin in deployment config."],"tags":["auth","security","config"],"analyzedSha":"c426bd93799de0f0e094c8f0582872c529d0ed0a","analyzedAt":"2026-08-04T21:52:59.219Z","schemaVersion":2}