mysql icon indicating copy to clipboard operation
mysql copied to clipboard

Cannot configure mysql auth_plugin to use when using MYSQL_PASSWORD environment variable

Open Zardozz opened this issue 10 months ago • 0 comments

When using the MYSQL_USER, MYSQL_PASSWORD Environment Variables to cause the docker-entrypoint.sh script to setup an initial database user, you cannot specify which auth_plugin to use and thus the user is setup with the default auth_plugin (caching_sha2_password) which might not be suitable for your use.

The user creation command as defined in https://dev.mysql.com/doc/refman/8.0/en/create-user.html allows you to specify the auth_plugin to use when creating a user.

Thus I suggest that docker_setup_db() of docker-entrypoint.sh script check for an additional Environment Variable like MYSQL_PASSWORD_PLUGIN

And then docker_process_sql --database=mysql <<<"CREATE USER '$MYSQL_USER'@'%' IDENTIFIED WITH '$MYSQL_PASSWORD_PLUGIN' BY '$MYSQL_PASSWORD' ;"

Then you could use other plugins like "mysql_native_password" if required

Zardozz avatar Mar 29 '24 22:03 Zardozz