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

WIP: Backport 0.4.x MySQL 8 Fixes to 0.3.x #935

Open
wants to merge 23 commits into
base: 0.3.x
Choose a base branch
from

Conversation

felixbuenemann
Copy link
Contributor

This backports the MySQL 8.0 fixes from the 0.4.x series to 0.3.x.

@sodabrew sodabrew added this to the 0.3.22 milestone Mar 19, 2018
@imiskolee
Copy link

@felixbuenemann are u still working on it. I will want to use MySQL 8.0 on an old ruby project.

@felixbuenemann
Copy link
Contributor Author

@imiskolee Have you tried bundling from the feature branch in my fork to see if it works?

The Travis CI logs are gone, so I don't know why they failed back then.

I have no recollection on which project I used it, but I'm pretty sure it worked fine.

The behavior that used to be triggered by EXPLAIN EXTENDED has been the
default for a long time and the previously deprecated EXTENDED keyword
was finally removed in MySQL 8.0.

To avoid breaking the spec on very old MySQL versions we just catch the
SQL syntax error and retry without the EXTENDED keyword.
@felixbuenemann
Copy link
Contributor Author

Looks like the Travis CI setup needs some love, I'll look into it.

Aside from that I fixed a missing return value for set_secure_auth on MySQL 8 due to an error in the original backport.

The specs could fail if the /etc/mysql directory contained files that
cannot be read by the user running the specs, eg. debian.cnf.

Since we already specify :sslca, the :sslcapath option doesn't make any
sense and can stay at the system default value.
@felixbuenemann
Copy link
Contributor Author

OK, tracked down the specs errors in docker. The reason was a bad setting of :sslcapath => '/etc/mysql/' in client_spec.rb that caused the /etc/mysql directory to be treated as a CA directory.

This caused problems, since the specs are running asn unpriviledged user and the directory contains some files that are only accessible by root, like debian.cnf.

Since the :sslcapath setting didn't make any sense when also setting :sslca, I simply dropped the setting.

The problem can also be reproduced with the mysql cli:

su nobody -c "mysql --ssl-capath=/etc/mysql/ --ssl-mode=REQUIRED --ssl=1 --ssl-cert=/etc/mysql/client-cert.pem --ssl-key=/etc/mysql/client-key.pem --ssl-ca=/etc/mysql/ca-cert.pem --ssl-cipher=DHE-RSA-AES256-SHA"
ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed
su nobody -c "mysql --ssl-mode=REQUIRED --ssl=1 --ssl-cert=/etc/mysql/client-cert.pem --ssl-key=/etc/mysql/client-key.pem --ssl-ca=/etc/mysql/ca-cert.pem --ssl-cipher=DHE-RSA-AES256-SHA"
ERROR 1045 (28000): Access denied for user 'nobody'@'localhost' (using password: NO)
# or connects fine with --user=root

The default dist is currently trusty, so the travis install scripts that
imply the old default of precise no longer work properly.

A better solution would be to update to the trusty (unsupported) or
xenial (supported) environment, but this should be the most minimal
change to restore the previous CI behavior.
This reverts commit d572951 because
Travis CI updates rubygems with important security fixes.
which should allow to use the preinstalled 2.3.3 version.
because it can no longher be installed due to missing binaries.

See: http://binaries.rubini.us/index.txt
caused by failing bundler install during rvm use.

Also the 2.3 version should be preinstalled.
because the specs require certs from .travis_ssl.sh installed in
/etc/mysql which is inaccessible without root on macOS.

A more involved fix would be to parameterize the paths in the specs and
adapt the .travis_ssl.sh script to work properly on macOS.
The latest MySQL 5.7 versions ingore SSL options, if connecting over a
UNIX socket and ssl-mode=REQUIRED/VERIFY_CA/VERIFY_IDENTITY is not set.

Since the :ssl_mode option is not implemented in 0.3, the easierst
workaround is to force connection over TCP by using the loopback IP.
It appears that none of the tested MySQL versions require this anymore.
This is required to allow password-less auth as root for the $USER.
@felixbuenemann felixbuenemann changed the title Backport 0.4.x MySQL 8 Fixes to 0.3.x WIP: Backport 0.4.x MySQL 8 Fixes to 0.3.x Apr 26, 2019
@felixbuenemann
Copy link
Contributor Author

Still working out some problems with MySQL 5.7 release versions and charset list, so added WIP marker.

I also have another branch were I updated CI to Trusty, since Precise is very deprecated and being phased out on Travis CI.

To reduce noise on this PR I'm doping that work on seperate branches with my own travis account.

sodabrew and others added 3 commits April 27, 2019 00:41
* Remove hardcoded dist names from scripts, reduce dependencies
* Switch from deprecated precise to trusty dist
* Update SSL script to force SHA1 for MySQL 5.5 w/yaSSL on Trusty
* Update MySQL install script to support MySQL 5.6 & 8.0 install
* Fix MariaDB downgrade 5.6 -> 5.5 on Trusty (remove old data dir)
* Update MariaDB install script to use latest MariaDB 10.x (10.3)
* Add DB=mysql8 to build matrix
* Add DB=mysql55 to build matrix, since MySQL 5.6 is pre-installed
and enabling fast finish, because compiling ree from source takes much
longer than all other builds and errors in ree but not in 1.8.7 are
highly unlikely.
@felixbuenemann
Copy link
Contributor Author

OK, CI is looking good now and was upgrade to Trusty / MySQL 5.6 as default, but MySQL 8.0 uses Xenial, due to lack of packages. An additional matrix entry downgrades to MySQL 5.5 on Trusty.

I've also found a bug with the encoding list, that I'll port over to master (see 091e1d5, 246013e) and added support for MariaDB 10.2 / 10.3.

@felixbuenemann
Copy link
Contributor Author

@sodabrew I think from the changes this PR is done.

Please let me know, if you'd like me to split it up into multiple PRs, since it now contains fixes for CI, MariaDB 10.2/10.3 and MySQL 8.0.

The CI changes also contain some fixes that are done in a similar fashion but slightly different on master…

@imiskolee
Copy link

beacuse the PXC 8.0 is coming, I am also blocking on this feature.

thanks @felixbuenemann. You're superman.

@felixbuenemann
Copy link
Contributor Author

@sodabrew Still waiting on some directions on how to proceed with this PR.

@felixbuenemann
Copy link
Contributor Author

@sodabrew Still waiting for feedback on this PR, see my comment from May 26th.

@ermacaz
Copy link

ermacaz commented May 2, 2023

+1

@waqarnazir340
Copy link

+1
Amazon RDS will be ending EOS support for MYSQL 5.7 on February 29, 2024, Some legacy Rails projects (version 3.x) do exist that are only compatible with mysql2 0.3.x version. This MYSQL 8 support in mysql2 0.3.x will be really helpful in cutting some project costs avoiding RDS MYSQL 5.7 EOL support.
@sodabrew your response on it will really be appreciated.

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

5 participants