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.
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
# 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?
Related Developer Error Solutions
Browse All 35 GuidesPostgreSQL: Remaining Connection Slots Reserved
Resolve PostgreSQL connection exhaustion caused by connection leaks or missing pooling with PgBouncer / Prisma Accelerate.
Prisma Error P1001: Can't Reach Database
Troubleshoot network connectivity, SSL certificates, wrong port mappings, and environment variable issues with Prisma ORM.
SQLite: Database is Locked (SQLITE_BUSY)
Resolve SQLite file lock contention during concurrent write transactions by enabling Write-Ahead Logging (WAL) and setting busy_timeout.