phpsword / sword-bundle

Modern WordPress development with Symfony
https://getsword.com
MIT License
124 stars 4 forks source link

Can't connect to the database :( #20

Closed sanchobor closed 4 months ago

sanchobor commented 1 year ago

Hi, guys,

I'm getting this: "error establishing a database connection" and can't debug it and connect the DB with the .env file. Is there something basic I'm missing? I'm not very familiar with docker and Symfony 6, I'm working with Symfony 4 mostly.

Regards, Boris

williarin commented 1 year ago

Hi, does this happen right after installation? If that's the case it's probably because the MySQL container is not ready yet. If it happens regardless of the timing, check if all containers are running in Docker Desktop (they should be green and not gray or red). Also check the logs of the MySQL container by clicking on it, and see if there's an error.

aroberts91 commented 4 months ago

I'm also having this issue. Appears the mysql container is failing to initialise due to the following error:

mysql_1    | 2024-05-02T14:59:48.142891Z 0 [ERROR] [MY-000067] [Server] unknown variable 'default-authentication-plugin=mysql_native_password'.
mysql_1    | 2024-05-02T14:59:48.143475Z 0 [ERROR] [MY-010119] [Server] Aborting

Looks to be an issue with the image command:

command: --default-authentication-plugin=mysql_native_password

I was able to resolve this temporarily by removing the db volume and specifically setting the version of the mysql image to mysql:8.0 but this is likely to create an issue with all future installs.

williarin commented 4 months ago

Indeed the compose files are outdated. This line should be removed. Also as MySQL is not semver, 8.1~8.4 are innovation releases and the compose image should be mysql:8.0 or mysql:8.0.37 for production use.

I'll make a fix soon but that will only apply to later installs unfortunately.

For existing installs, a manual upgrade of the password is necessary for production databases, or recreate it completely as you mentioned.

williarin commented 4 months ago

It's fixed with the latest installer. I've restricted MySQL to 8.0.37 and removed mysql_native_password.