fix: handle passwords with special characters in health check
The health check was failing when MySQL passwords contained special characters like # because it was sourcing .env as a bash script, where # is treated as a comment. Solution: Remove unnecessary .env sourcing and use environment variables directly from the db container, which Docker Compose has already correctly parsed from .env. This fixes the "Impossible de se connecter à MySQL" error when passwords contain #, $, !, or other special characters. Benefits: - Works with any special characters in passwords - Simpler code (removed 4 lines) - More reliable (uses container's environment directly) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -131,19 +131,12 @@ echo "▶ Base de données:"
|
||||
if docker-compose exec -T db mysqladmin ping -h localhost --silent 2>/dev/null; then
|
||||
check_ok "MariaDB répond"
|
||||
|
||||
# Charger .env pour tester la connexion
|
||||
if [ -f .env ]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1091
|
||||
source .env
|
||||
set +a
|
||||
|
||||
if docker-compose exec -T db sh -c "MYSQL_PWD=\"\$MYSQL_PASSWORD\" mysql -u\"\$MYSQL_USER\" \"\$MYSQL_DATABASE\" -e 'SELECT 1' >/dev/null 2>&1"; then
|
||||
# Tester la connexion MySQL (utilise les variables d'environnement du container)
|
||||
if docker-compose exec -T db sh -c 'MYSQL_PWD="$MYSQL_PASSWORD" mysql -u"$MYSQL_USER" "$MYSQL_DATABASE" -e "SELECT 1"' >/dev/null 2>&1; then
|
||||
check_ok "Connexion MySQL fonctionnelle"
|
||||
else
|
||||
check_fail "Impossible de se connecter à MySQL"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
check_fail "MariaDB ne répond pas"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user