MySQL 8.4.0 version kicked me below the waist line
Fix for the unknown variable 'default-auth=mysql_native_password'

I've discovered coding back in 2013 and three years later I spent all my summer building my first Laravel app which is still in production by the non-profit I've built for.
Now I'm struggling to find the balance between enjoying the power of "I can build this myself" and not chocking myself to death trying to build everything myself.
As it is common for developers to be less articulate, I decided to leverage writing about my endeavours, to keep me up.
TL DR
If you're coming from google because you saw unknown variable 'default-auth=mysql_native_password'. - all you need to do is to change --default-authentication-plugin=mysql_native_password to --mysql-native-password=ON.
Story
I recently did a deployment where a docker compose project had own mysql that was only pinned to the version mysql:8. The config snippet below.
mysql:
image: mysql:8
restart: always
command: --default-authentication-plugin=mysql_native_password
volumes:
- db_data:/var/lib/mysql
- db_socket:/var/run/mysqld
environment:
- MYSQL_DATABASE=xxxxx
- MYSQL_ROOT_PASSWORD=xxxxx
healthcheck:
test: ['CMD', 'mysqladmin', 'status', '-hlocalhost', '-uroot', '-pxxxxxx']
interval: 1m
timeout: 5s
retries: 3
start_period: 1m
Immediately one could point out that it's a huge mistake to only pin by a major version. For a truly production project, I would almost never host my own database - aka, I would always use a managed one.
Anyhow, this one slipped through and caused completely unnecessary downtime.
Debugging
After looking through the looks I could see mysql 8.4.0 Plugin 'mysql_native_password' is not loaded and unknown variable 'default-auth=mysql_native_password' lines and that the server is shutting down.
Almighty Google!
That means I started surfing. Since it was released just two days ago (on April 30th), there weren't any immediately results that seemed relevant as deemed by my brains.
Based on that, I searched for change log/release log. I land on this page https://dev.mysql.com/doc/relnotes/mysql/8.4/en/news-8-4-0.html and do Cmd + F (search in page) to see if there has been anything regarding the plugin.
Boom, lucky result under "Deprecation and Removal Notes" section
Important Change: The deprecated
mysql_native_passwordauthentication plugin is now disabled by default. It can be enabled by starting MySQL with the new--mysql-native-password=ONserver option, or by addingmysql_native_password=ONto the[mysqld]section of your MySQL configuration file.
That led me to update the compose config and fix the downtime.
mysql:
image: mysql:8.4
restart: always
command: --mysql-native-password=ON
volumes:
- db_data:/var/lib/mysql
- db_socket:/var/run/mysqld
environment:
#....
That's it. I hope by writing this I won't land on this mistake again. Restoring from backup is such as boring thing to do.
Or maybe it's a sign to stop procrastinating migration to pg... would be lovely to leverage Cloudflare's hypertunnel...



