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

Compatibility Issue: mysql2 Gem with Ruby 2.3.7, Rails 3.x, and MySQL 5.7 #1386

Open
rk-panchal opened this issue Dec 5, 2024 · 3 comments

Comments

@rk-panchal
Copy link

rk-panchal commented Dec 5, 2024

@brianmario #304
I am experiencing compatibility issues when using the mysql2 gem with the following setup:

Ruby version: 2.3.7
Rails version: 3.2.x
MySQL version: 5.7.x (deprecated after August 10, 2024).
mysql2 gem versions attempted: 0.3.18, 0.3.21

Please proivde a solution how can use myql2 with rails 3.
Note: I am not looking for updating the rails

@rk-panchal
Copy link
Author

If i tried with updataed version of mysql2(0.4.10)

/Users/ravinderkumar/.rvm/gems/ruby-2.3.7/gems/bundler-1.17.3/lib/bundler/rubygems_integration.rb:408:in block (2 levels) in replace_gem': Please install the mysql2 adapter: gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.10. Make sure all dependencies are added to Gemfile.) (LoadError)

image

@Faq
Copy link

Faq commented Dec 5, 2024

Here they use old Rails version #1349 works with 0.3.19 and Mysql5.7
btw can't access your image as it is private.

@sodabrew
Copy link
Collaborator

sodabrew commented Dec 5, 2024

If you need to maintain this older version of Rails but newer mysql2 gem in order to use a newer MySQL database, I recommend making a fork of rails on your version branch and then modifying the mysql2 adapter to accommodate the newer version.

Make a fork and set this as your default branch: https://github.com/rails/rails/tree/3-2-stable

Go to this file:
https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb#L1-L6

Modify line 3 to indicate a newer mysql2 gem version:

require 'active_record/connection_adapters/abstract_mysql_adapter'

gem 'mysql2', '~> 0.3.10'
require 'mysql2'

In your project's Gemfile, change your rails gem reference to your fork: https://bundler.io/guides/git.html

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

No branches or pull requests

3 participants