Posted 6 months ago. Visible to the public.

Running Rails 2 apps with modern MariaDB SQL server

You might have some trouble running a Rails LTS 2 app with MySQL 5.7.

If you don't want to hack Mysql 5.6 into your modern Ubuntu or use the MySQL sandbox, you might want to try MariaDB 10.x.

MariaDB 10.x should work with both old and new Rails applications.

Switch to MariaDB

Remove MySQL:

Copy
sudo apt remove mysql-common mysql-client mysql-server mysql-apt-config

Install MariaDB:

Copy
sudo apt install mariadb-server mariadb-client mariadb-common libmariadb2

You should now have MariaDB 10.x. Check with mysql --version.

You still need the MySQL development headers so you can build the mysql and mysql2 gems:

Copy
sudo apt install libmysqlclient-dev

Rebuild gems

This should be unnecessary, but we include it just in case your MySQL adapter gem fails to load.

For every version of Ruby installed, remove the mysql and mysql2 gems:

Copy
gem uninstall --all mysql mysql2

The next time to work on a Rails project a bundle install will get you back the gems.

Run tests

Now run your test suite to see if the migration was successful.

Troubleshooting: Use an SQL compatibility mode

If you get unexpected SQL errors related to the handling of missing or invalid values, you need to either fix your app or remove the STRICT_TRANS_TABLES SQL mode flag that is default in MariaDB 10.2.

Note that if you switch to a more liberal SQL mode for your app, you must make sure that all developers, staging server and production server use the same SQL mode.

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:

Avatar
Henning Koch
Last edit:
6 months ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more