friends-of-reactphp / mysql

Async MySQL database client for ReactPHP.
MIT License
334 stars 66 forks source link

Support `caching_sha2_password` authentication (MySQL 8+) #112

Open nazar-pc opened 5 years ago

nazar-pc commented 5 years ago

MySQL 8 does not seem to be supported by this library, any plans to add such support?

clue commented 5 years ago

@nazar-pc What problem are you seeing exactly? I haven't had a chance to give it a try yet, but if we can identify something that needs to be changed to support MySQL 8, we will take a look as soon as time permits :+1:

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password suggests it should be compatible for the most part. We should support caching_sha2_password as the default authentication plugin.

nazar-pc commented 5 years ago

I get an exception during connection like this:

{
    "code": 1251,
    "message": "Client does not support authentication protocol requested by server; consider upgrading MySQL client"
}
theUniC commented 5 years ago

It's nothing about the library (except for the caching_sha2_password authentication plugin). If you want to make this library work you should make your mysql work with the mysql_native_password authentication plugin.

https://www.php.net/manual/en/mysqli.requirements.php https://stackoverflow.com/questions/50026939/php-mysqli-connect-authentication-method-unknown-to-the-client-caching-sha2-pa

recarv commented 4 years ago

I've been able to connect using the mysql_native_password authentication.

mmoreram commented 3 years ago

@clue I think that this issue can be closed :)

kodmanyagha commented 11 months ago

I faced an interesting thing. I changed caching_sha2_password to mysql_native_password but I still get same error. The solution is set bindto value in Connector class. For example:

        $connector = new Connector([
            'dns' => '127.0.0.1',
            'tcp' => [
                // We have to set this correct, otherwise you get that error:
                // https://github.com/friends-of-reactphp/mysql/issues/112
                //'bindto' => '192.168.0.1:0',
                'bindto' => '127.0.0.1:0',
            ],
            'tls' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        ]);
SimonFrings commented 11 months ago

@kodmanyagha Thanks for your input on this, but I don't think this solved the problem the way you intended to. I can only guess as I don't know all the details here, perhaps you're using different authentication methods when connecting to different databases?

There are some helpful answers in here and I agree with @clue that support caching_sha2_password as the default authentication plugin should be a thing in the future to fully support MySQL 8. We could agree that the original question in this ticket seems to be answered (as @mmoreram rightfully pointed out to close this ticket), but I think we should leave this open and understand this more like feature request to support MySQL 8.