Website/Application Database Connection Fails After Upgrading to MySQL 8.4 (Authentication Plugin Incompatibility)
After upgrading a production database from 8.0 to 8.4 LTS, older clients such as PHP websites and Navicat report database connection errors and the site goes down. Logs commonly show "Authentication plugin 'caching_sha2_password' cannot be loaded" or "Plugin 'mysql_native_password' is not loaded" (ERROR 1524).
View cause and solution
MySQL 8.4 disables the mysql_native_password plugin by default in favour of caching_sha2_password, so existing accounts still using the old plugin stop working immediately after the upgrade. The mysqlnd driver in PHP 7.4 does not support caching_sha2_password and therefore always fails to connect. In addition, passwords containing characters such as ! trigger Bash history expansion when running SQL and produce an "event not found" error.
1) Before upgrading (mandatory): check every account with SELECT user,host,plugin FROM mysql.user; and migrate accounts that must stay compatible with older clients in advance: ALTER USER 'dbuser'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password'; (if the password contains !, run set +H to disable history expansion, or execute the SQL through a heredoc).
2) For legacy applications such as PHP 7.4: the account must be created explicitly with IDENTIFIED WITH mysql_native_password BY 'password'; (this plugin is disabled by default in MySQL 8.4; it can be re-enabled by setting mysql_native_password=ON and restarting, but upgrading the client is preferable to depending on it long term).
3) After the upgrade: test with real clients and confirm that every consumer (website, scripts, BI) works before opening traffic to the public.