Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db:dump uses invalid mysqldump command when Magento db connection uses SSL #1526

Open
mfickers opened this issue Sep 27, 2024 · 2 comments
Open
Assignees
Labels

Comments

@mfickers
Copy link

Describe the bug

Database connection runs over SSL, here is an excerpt from the env.php:

    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => '████████',
                'dbname' => 'magento2',
                'username' => '████████',
                'password' => '████████,
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'driver_options' => [
                    1009 => '/etc/ssl/cert.pem'
                ]
            ]
        ]
    ],

When running db:dump, I get an error regarding the --ssl-mode parameter:

$ n98-magerun2 db:dump --compression=gzip --no-tablespaces var/magento2.sql.gz


  Dump MySQL Database


Start dumping database magento2 to file var/magento2.sql.gz
mysqldump: unknown variable 'ssl-mode=VERIFY_CA'

In Exec.php line 51:

  Exit status 7 for command set -o pipefail; mysqldump --single-transaction --quick --no-tablespaces -h'████████' --ssl-ca='/etc/ssl/cert.pem' -
  -ssl-mode=VERIFY_CA -u'████████' --password='████████' 'magento2' | LANG=C LC_CTYPE=C LC_ALL=C sed -E 's/DEFINER[ ]*=[ ]*`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g
  ' | gzip -c  > 'var/magento2.sql.gz' 2>&1. Output was:


db:dump [--connection CONNECTION] [-t|--add-time [ADD-TIME]] [-c|--compression COMPRESSION] [--only-command] [--print-only-filename] [--dry-run] [--set-gtid-purged-off] [--no-single-transaction] [--human-readable] [--git-friendly] [--add-routines] [--no-tablespaces] [--stdout] [-s|--strip [STRIP]] [-e|--exclude [EXCLUDE]] [-i|--include [INCLUDE]] [-f|--force] [--keep-column-statistics] [--keep-definer] [--] [<filename>]

Expected behaviour

db:dump is able to connect to the database using the configured connection from Magento.

Steps to reproduce the issue

  1. Configure Magento to connect to database over SSL
  2. Run magerun db:dump

Technical details

  • Docker Image based on Alpine Linux v3.20
  • mysqldump Ver 10.19 Distrib 10.11.8-MariaDB, for Linux (x86_64)
  • n98-magerun2 7.4.0 (commit: 94ac790) by netz98 GmbH
  • Magento ver. 2.4.7-p2
  • Database uses MySQL 8.0.32

Possible Fix

My workaround is to add --only-command parameter to the db:dump command. Then I modify the mysqldump command by removing the --ssl-mode parameter.

@mfickers mfickers added the bug label Sep 27, 2024
@cmuench cmuench self-assigned this Sep 27, 2024
@cmuench
Copy link
Member

cmuench commented Sep 27, 2024

@mfickers ok that's tricky. We map the DB config of Magento to the external mysqldump parameters. Currently we support only a set of all the options. I will try to find a solution.

@cmuench
Copy link
Member

cmuench commented Sep 27, 2024

ok. Looks like it's not so easy to setup MySQL with SSL in my ddev box... I just spent two hours with only a bit progress to setup the environment in my dev box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants