go-sql-driver/mysql · error
this user requires clear text authentication. If you still w
Error message
this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN
What it means
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.
Source
Thrown at errors.go:23
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
package mysql
import (
"errors"
"fmt"
"log"
"os"
)
// Various errors the driver might return. Can change between driver versions.
var (
ErrInvalidConn = errors.New("invalid connection")
ErrMalformPkt = errors.New("malformed packet")
ErrNoTLS = errors.New("TLS requested but server does not support TLS")
ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN")
ErrNativePassword = errors.New("this user requires mysql native password authentication")
ErrOldPassword = 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")
ErrUnknownPlugin = errors.New("this authentication plugin is not supported")
ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+")
ErrPktSync = errors.New("commands out of sync. You can't run this command now")
ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?")
ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the `Config.MaxAllowedPacket`")
ErrBusyBuffer = errors.New("busy buffer")
// errBadConnNoWrite is used for connection errors where nothing was sent to the database yet.
// If this happens first in a function starting a database interaction, it should be replaced by driver.ErrBadConn
// to trigger a resend. Use mc.markBadConn(err) to do this.
// See https://github.com/go-sql-driver/mysql/pull/302
errBadConnNoWrite = errors.New("bad connection")
)
var defaultLogger = Logger(log.New(os.Stderr, "[mysql] ", log.Ldate|log.Ltime))
View on GitHub (pinned to c426bd9379)
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.
Example fix
// before dsn := "u:p@tcp(host:3306)/db" // after dsn := "u:p@tcp(host:3306)/db?tls=true&allowCleartextPasswords=1"
Defensive patterns
Strategy: validation
Validate before calling
if usesCleartextPlugin {
if !tlsEnabled {
return errors.New("refusing cleartext password without TLS")
}
dsn += "&allowCleartextPasswords=1"
} Try / catch
if errors.Is(err, mysql.ErrCleartextPassword) {
// add allowCleartextPasswords=1 (with TLS) and retry, or surface to user
} Prevention
- Always pair allowCleartextPasswords=1 with tls=true.
- Prefer hashing plugins for new accounts.
- Document the account's auth plugin in deployment config.
When it happens
Trigger: 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.
Common situations: Connecting to a MySQL/Aurora/RDS account backed by PAM or LDAP; enterprise SSO setups; accounts created with `IDENTIFIED WITH mysql_clear_password`.
Related errors
- invalid value / unknown server pub key name: {cfg.ServerPubK
- invalid bool value: {value}
- this user requires mysql native password authentication
- this user requires old password authentication. If you still
- invalid DSN: did you forget to escape a param value?
AI-assisted analysis of go-sql-driver/mysql@c426bd9379 (2026-08-04).
Data as JSON: /data/errors/61e17940aa6a4d82.json.
Report an issue: GitHub.