docker-library / wordpress

Docker Official Image packaging for WordPress
https://wordpress.org/
GNU General Public License v2.0
1.78k stars 1.07k forks source link

CLI variant fails connecting to MySql server via caching_sha2_password #862

Open febsn opened 10 months ago

febsn commented 10 months ago

I'm using a docker-compose setup consisting of a mysql:8.0, a wordpress:6 and a wordpress:cli container. Wordpress itself works fine, but the CLI failed to connect to the server saying:

Failed to get current SQL modes. Reason: ERROR 1045 (28000): Plugin caching_sha2_password could not be loaded: Error loading shared library /usr/lib/mariadb/plugin/caching_sha2_password.so: No such file or directory

I dug deeper and found out that the underlying php:8.x-alpine image doesn't seem to include the necessary libraries per default, but they can be added by installing the mariadb-connector-c package (see: https://github.com/arey/mysql-client/issues/5)

I can confirm; it now works, using the following hacky Dockerfile for the cli:

FROM wordpress:cli

USER root
RUN apk add --no-cache mariadb-connector-c

USER www-data

I'd suggest that the package be included in the wordpress:cli variant. Supposedly it could be added in https://github.com/docker-library/wordpress/blob/master/Dockerfile.template after line 17 – I don't feel competent enough for a PR…