Installing old versions of mysql2 on Ubuntu 20.04+
On some of our older projects, we use the mysql2 gem. Unfortunately, versions 0.2.x (required for Rails 2.3) and versions 0.3.x (required for Rails 3.2) can no longer be installed on Ubuntu 20.04. Trying this either leads to errors when compiling the native extension, or a segfaults when using it.
For Rails 4.2, mysql2 version 0.4.10 seems to work okay.
To install it, you have to switch the mysql2 gem to our fork. In your Gemfile, change mysql2 to either
gem 'mysql2', :git =>'https://github.com/makandra/mysql2', :branch => '0.2.x-lts' # for Rails 2.3
gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.3.x-lts' # for Rails 3.x
If you run into issues when compiling, make sure you have
sudo apt install libmariadb-dev