Posted 23 days ago. Visible to the public.

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 =>'', :branch => '0.2.x-lts' # for Rails 2.3


gem 'mysql2', git: '', branch: '0.3.x-lts' # for Rails 3.x

If you run into issues when compiling, make sure you have libmariadb-dev installed:

sudo apt install libmariadb-dev
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Tobias Kraze
Last edit:
22 days ago
by Tobias Kraze
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more