Skip to content

How can I enable legacy mysql #417

Closed

Description

@electricmessiah

I'm trying to get some old sites working that use deprecated mysql_connect(). Is there an environment var I can use in my stack to enable the legacy 5.6 mysql as the example below?

PHP 5.6 was the last version to support the original mysql_connect() function. 
If your WordPress site is very old (pre-v3.9), it must have the mysql extension, not just mysqli. 
environment:
      - PHP_EXTENSIONS=mysql mysqli pdo_mysql

Activity

  1. electricmessiah commented on Apr 26, 2026

    @electricmessiah
    Author

    Solved with this, but is there an easier/cleaner way?

    entrypoint: ["/bin/sh", "-c"]
        command: 
          - |
            if command -v phpaddmod >/dev/null 2>&1; then
              phpaddmod mysql mysqli pdo_mysql
            elif command -v php-extension >/dev/null 2>&1; then
              php-extension install mysql mysqli pdo_mysql
            else
              echo "No helper found, attempting manual enable"
              docker-php-ext-install mysql mysqli pdo_mysql
            fi
            /usr/local/sbin/php-fpm
    
  2. jhmckimm commented on May 6, 2026

    @jhmckimm

    Solved with this, but is there an easier/cleaner way?

    Create your own Dockerfile that is based on the shinsenter image you wish to use, and simply run RUN phpaddmod mysql, i.e:

    FROM shinsenter/php:8.5-fpm-nginx@sha256:b9b9a7a5b9ef8b2f67fc400a124c8f9e24b67a18c53183319cf7c8a2c062e80c
    
    RUN phpaddmod xdebug
  3. shinsenter commented on May 18, 2026

    @shinsenter
    Owner

    @electricmessiah cc @jhmckimm
    While I don't recommend installing PHP extensions at container startup, if you need to, please refer to this discussion on installing an extension via a startup script.
    #261

  4. Repository owner locked and limited conversation to collaborators on May 18, 2026
  5. converted this issue into a discussion #420 on May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions