Skip to content

Conversation

@bmiguelbc16
Copy link
Contributor

Pull Request: Fix MySQL Connection Timeout in Automatic WordPress Installation

Contributor Information

Subject Details
Author MiguelBc
Date October 29, 2025
Host Operating System Fedora Linux (KDE)
Relevant Software Versions Docker: Docker Compose v2.29.7, PHP 8.3.x, Composer 2.x

1. Problem Summary

The php antonella serve command presented two critical issues that hindered a smooth experience in active development environments:

  1. MySQL Connection Timeout: The initialization script was failing to connect to the MySQL database due to SSL certificate verification errors. The script would wait indefinitely without a timeout mechanism, leaving WordPress in a partially installed state and requiring manual intervention.

  2. Excessive Warnings in Logs: The installation process generated numerous warnings from WP-CLI (PHP warnings about WP_DEBUG constant) and permission errors on Linux systems. This generated a conflict where logs were already cluttered with unnecessary warnings, preventing a clean installation experience.

2. Description of the Implemented Solution

This commit introduces a comprehensive solution addressing both problems, significantly enhancing the robustness of the development environment.

2.1. MySQL Connection Fix Implementation

The core issue was that MySQL 8.0 uses self-signed SSL certificates by default, causing mysqladmin ping to fail with certificate verification errors. The solution implements:

  • SSL Bypass: Added --skip-ssl flag to mysqladmin command to bypass SSL certificate verification
  • Timeout Mechanism: Implemented a 120-second timeout with a retry counter that logs progress every 10 seconds
  • Error Handling: Script now exits with clear error messages if MySQL is unreachable, providing troubleshooting hints

2.2. Enhanced Docker Configuration

Modified docker-compose.yaml to improve MySQL readiness detection:

  • Enhanced healthcheck with credential validation: mysqladmin ping -u wordpress -pwordpress
  • Increased healthcheck parameters: interval: 5s, timeout: 10s, retries: 20, start_period: 30s
  • Increased initial wait time in entrypoint.sh from 10s to 30s for better reliability

2.3. Clean Logs Implementation

Suppressed all unnecessary warnings and notices:

  • Added --quiet flag and 2>/dev/null redirection to all WP-CLI commands
  • Fixed Linux permission errors by excluding host-mounted directories (plugins, debug.log) from chown/chmod operations
  • Removed deprecated "developer" plugin from installation script
  • Improved status messages throughout the installation process

3. Results

Before

  • ❌ MySQL connection timeout after indefinite wait
  • ❌ Manual WordPress installation required
  • ❌ Logs filled with warnings and permission errors

After

  • ✅ MySQL connects successfully within seconds
  • ✅ 100% automatic WordPress installation
  • ✅ Clean, readable logs with clear progress indicators
  • ✅ Cross-platform compatibility maintained

4. Files Modified

  • docker-compose.yaml - Enhanced MySQL healthcheck configuration
  • docker/entrypoint.sh - Increased wait time and added logging
  • docker/init-wordpress.sh - Fixed timeout, SSL issues, and suppressed warnings

@cehojac
Copy link
Owner

cehojac commented Nov 6, 2025

@bmiguelbc16 por lo visto cuando hacer php antonella serve o docker-compose up se queda pillado en la ejecución de script en el servicio wordpress:

wp-antonella exited with code 255                                                                                                                     
wp-antonella          | exec /docker-scripts/entrypoint.sh: no such file or directory                                                                 
wp-antonella          | exec /docker-scripts/entrypoint.sh: no such file or directory                                                                 
wp-antonella          | exec /docker-scripts/entrypoint.sh: no such file or directory                                                                 
wp-antonella          | exec /docker-scripts/entrypoint.sh: no such file or directory  

se queda de forma permanente no continuando con el montaje,

hemos probado en tu rama

git checkout -- docker/*.sh

pero sigue sin funcionar. Saludos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants