trilogy-libraries / trilogy

Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.
MIT License
697 stars 68 forks source link

Connection Fails in GitHub Actions #162

Closed mountaindog closed 5 months ago

mountaindog commented 6 months ago

I have noticed this a couple of times. Installing the Trilogy Gem locally and connecting to MySQL (8.3.0) works without issues. However, when used in GitHub Actions, it generates this error:

ActiveRecord::ConnectionNotEstablished: trilogy_auth_recv: TRILOGY_UNEXPECTED_PACKET (ActiveRecord::ConnectionNotEstablished)

A little further down the stack, this:

Caused by:
Trilogy::QueryError: trilogy_auth_recv: TRILOGY_UNEXPECTED_PACKET (Trilogy::QueryError)

My GitHub actions are using the latest MySQL. I am happy to provide more information if needed. Hopefully, I just needed to include a setting or config option.

Rails 7.1 Ruby: 3.2.2 MySQL (8.3.0)

bensheldon commented 6 months ago

I think you are running into Trilogy's current non-support with caching_sha2_password. You'll need to put MySQL into mysql_native_password mode.

Here's many examples you might look at for doing so:

https://github.com/search?type=code&q=path%3A.github%2Fworkflows%2F*+%22--default-authentication-plugin%3Dmysql_native_password%22

kmcphillips commented 6 months ago

I got hung up on this for hours. I think I had an issue with loading the wrong MySQL config a second time and stomping the guidance above.

Anyway, there's my ci.yml for a pretty standard Rails app using Trilogy, if that helps: https://gist.github.com/kmcphillips/55043742fcf6e882a7e2eb90611a4910

eileencodes commented 5 months ago

I'm going to close this because we already have an open issue for caching_sha2_password.