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

Avoid double semicolon in the generated DSN, which could cause MySql connection error. #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hailong
Copy link
Member

@Hailong Hailong commented Aug 28, 2019

I have a Magento 2 website which was migrated from Magento 1, and it has the following DB connection settings.

As can be seen from the code snippet below, it has a 'initStatements' field there and its value is a SQL statement with semicolon at the end.

This would cause an extra semicolon generated in the middle of DSN, so two semicolons in the string. Originally it works fine with my local MySql DB on that server, while it stops working when I migrate to DigitalOcean database service recently.

Just googled around, somebody else suffer the same problem too, and reported a Magento 2 bug at magento/magento2#6526

I'm feeling this is not a special case only for me, more over it does take time to figure it out. So I'd like to suggest a code change here to get rid of this issue smoothly.

    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'my-db-server:25060',
                'dbname' => 'mydatabasename',
                'username' => 'dbuser',
                'password' => 'dbuserpassword',
                'active' => '1',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;'
            ]
        ]
    ],

@magento-cicd2
Copy link

magento-cicd2 commented Aug 28, 2019

CLA assistant check
All committers have signed the CLA.

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.

None yet

2 participants