Running Rails 2 apps with modern MariaDB SQL server
You might have some trouble running a Rails LTS 2 app with MySQL 5.7.
MariaDB 10.x should work with both old and new Rails applications.
Switch to MariaDB
sudo apt remove mysql-common mysql-client mysql-server mysql-apt-config
sudo apt install mariadb-server mariadb-client mariadb-common libmariadb2
You should now have MariaDB 10.x. Check with
You still need the MySQL development headers so you can build the
sudo apt install libmysqlclient-dev
mysql2 gems installed on your machine are still built against the
mysql-client package you just uninstalled, so you will probably get this error when booting your Rails app:
RuntimeError: Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (libmysqlclient.so.18: cannot open shared object file: No such file or directory - /home/henning/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/mysql2-0.2.24/lib/mysql2/mysql2.so)
You can fix this by re-installing the gems.
For every version of Ruby installed, remove the
gem uninstall --all mysql mysql2
The next time to work on a Rails project a
bundle install will get you back the gems.
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.