EC-CUBEにはdocker-compose.ymlが用意されていますが、MySQLのコンテナ項目を見てみるとmyql5.7のイメージが仕様されています。これを8.0に変更してみます。
※EC-CUBE4はMySQL8を正式にはサポートしていないようです。
https://doc4.ec-cube.net/quickstart_requirement

docker-compose.ymlを8.0に変更してみる

デフォルトのdocker-compose.yml

mysql:
image: mysql:5.7

これをimage:mysql8.0に変更すれば解決・・! と思いきや、インストールコマンド実行時にエラーに発生します。

[ERROR] The command “bin/console doctrine:database:create –if-not-exists” failed.

Exit Code: 1(General error)

Working directory: /var/www/html

Output:
================

Error Output:
================
22:19:22 ERROR [console] Error thrown while running command “doctrine:database:create –if-not-exists”.
Message: “An exception occurred in driver: SQLSTATE[HY000] [2054] The server requested authentication method
unknown to the client” [“exception” => Doctrine\DBAL\Exception\DriverException { …},”command” =>
“doctrine:database:create –if-not-exists”,”message” => “An exception occurred in driver: SQLSTATE[HY000]
[2054] The server requested authentication method unknown to the client”] [“file” =>
“/var/www/html/vendor/symfony/console/EventListener/ErrorListener.php”,”line” => 48,”class” =>
“Symfony\Component\Console\EventListener\ErrorListener”,”function” => “onConsoleError”,”uid” =>
“xxxxxxx”,”user_id” => “N/A”,”session_id” => “N/A”]

In AbstractMySQLDriver.php line 106:

An exception occurred in driver: SQLSTATE[HY000] [2054] The server requeste
d authentication method unknown to the client

In PDOConnection.php line 31:

SQLSTATE[HY000] [2054] The server requested authentication method unknown t
o the client

In PDOConnection.php line 27:

SQLSTATE[HY000] [2054] The server requested authentication method unknown t
o the client

In PDOConnection.php line 27:

PDO::__construct(): The server requested authentication method unknown to t
he client [caching_sha2_password]

doctrine:database:create [–shard SHARD] [–connection [CONNECTION]] [–if-not-exists] [-h|–help] [-q|–quiet]
[-v|vv|vvv|–verbose] [-V|–version] [–ansi] [–no-ansi] [-n|–no-interaction] [-e|–env ENV] [–no-debug]
[–] <command>

 

エラーの原因

このエラーはmysql:8.0で認証プラグインがcaching_sha2_passwordに変更され、クライアント側がそれに対応をしていないためです。
docker-compose.ymlに下記のcommandを追加してupやることで認証プラグインがmysql_native_passwordに変更され、Docker上のEC-CUBEをインストール・動作させることが可能です。

mysql:
image: mysql:8.0
command: –default-authentication-plugin=mysql_native_password

日本発!ECオープンプラットフォーム「EC-CUBE」 EC-CUBEゴールドパートナー EC-CUBEは株式会社イーシーキューブの商標です

EC-CUBEカスタマイズに関するお問い合わせはこちら


    [重要]現在公式にセキュリティサポートが切れていないPHPは8.1以上、MySQLは8.0以上で、対応しているEC-CUBEバージョンは4.2以上です。古いEC-CUBEを使っている方は適切なタイミングでバージョンアップをご検討ください。

    EC-CUBEバージョンアップ