Dynamic connection to MySQL database in Ruby on Rails (mysql2) mysql, ruby on rails April 7, 2012 Max Ivak The following code connects to mysql database and retrieves some data.