Compatibility Issue: mysql2 Gem with Ruby 2.3.7, Rails 3.x, and MySQL 5.7
@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
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)
Here they use old Rails version https://github.com/brianmario/mysql2/issues/1349 works with 0.3.19 and Mysql5.7 btw can't access your image as it is private.
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