Open colinframe opened 1 year ago
I speculate the problem is related to an issue in the trilogy
gem where it cannot support caching_sha2_password
- see this issue
I had to make these changes to use the adapter on GitHub CI. Essentially you need to ensure the user is IDENTIFIED WITH mysql_native_password
run: |
sudo service mysql start
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
+ mysql -e "CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
+ mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;" -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
+ mysql -e "FLUSH PRIVILEGES;" -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
@gstark thanks for the snippet! You're creating a new user (test@localhost
) by using the authority of the default/root user (your DB_USER
+ DB_PASSWORD
) — are you telling Trilogy somewhere to use this new user (test@localhost
) rather than the DB_USER
/ DB_PASSWORD
env vars?
Yes, in my setup, I am manually setting DATABASE_URL
to use this new test
user. I think you could modify the existing {{ env.DB_USER }}
to use mysql_native_password
- though I have not checked to see how to change that.
I didn't end up getting this working (had to move on to other things) but hope I can come back at some point and get it going!
Hi there,
I'm in the process of moving a Rails 7 app over to Trilogy and whilst locally everything Just Worked using
database.yml
orDATABASE_URL
as a config I'm getting an error when using theDATABASE_URL
env variable in Github actions for CI. Previously I had themysql2
adapter working fine on GA usingDATABASE_URL
.The error I'm seeing is
Trilogy::QueryError: trilogy_auth_recv: TRILOGY_UNEXPECTED_PACKET
.I'm not using any specific config options on the CI mysql service but locally I am starting up the docker compose service with the following, in case that makes a difference
command: [ "--default-authentication-plugin=mysql_native_password", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--innodb_monitor_enable=all" ]
I'm using the latest versions of
trilogy
,active record-trilogy-adapter
andrails
.The output I get from the GA CI run is as follows;
Any help would be greatly appreciated!