Fix for mysql2 error "Incorrect MySQL client library version! This gem was compiled for x.x.x but the client library is y.y.y."

Posted . Visible to the public.

This should be fixed in the latest LTS-branches of our mysql2 fork Show archive.org snapshot , 0.2.x-lts and 0.3.x-lts.

Use

gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.2.x-lts' # for Rails 2.x
gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.3.x-lts' # for Rails 3.x

in your Gemfile, and do a

bundle update mysql2

Background

mysql2 used to check that the client library used at runtime actually matches the one it was compiled against. However, at least on Ubuntu 22.04, the mariadb library files themselves seem to report 2 conflicting versions.

The fix simply removes that check on non-Windows platforms (as is the case in current mysql2 versions), reasoning that Linux should enforce this anyways.

Tobias Kraze
Last edit
Tobias Kraze
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2022-07-29 11:40)