Skip to main content
Database & ORM · Developer Error Resolution Lab

Fix MySQL 'ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol'

Update MySQL 8 user authentication plugin from caching_sha2_password to mysql_native_password.

Triggered Error Message:

Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

Customize Solution for Your Environment
# Option 1: Upgrade to 'mysql2' package (Native SHA-256 Support):
npm uninstall mysql && npm install mysql2

# Option 2: Run SQL in MySQL terminal to alter user:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'my_secure_password';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'my_secure_password';
FLUSH PRIVILEGES;

Root Cause & Mechanism Analysis

Why does this error occur?

MySQL 8.0 defaulted to `caching_sha2_password` authentication, which older Node.js `mysql` client drivers do not support.

Frequently Asked Questions

Why is mysql2 preferred over modifying MySQL 8 server defaults?
`mysql2` supports modern async/await promises and native SHA256 authentication without degrading database security.
Browse All 35 Guides