App Platform - Database connection protocol "mysql" instead of "mysql2" for Rails app

I’m trying to set-up my first application using the App Platform - it’s a Ruby on Rails application that I’m trying to link to an existing MySQL database.

The default behaviour sets a DATABASE_URL environment variable with the correct connection string - it begins mysql://

However, in Ruby on Rails, this tries to use the older “mysql” gem, instead of the “mysql2” gem. (The older gem isn’t compiling for me.)

I believe this would work if DATABASE_URL began with mysql2:// - but I can’t seem to find any way to change that protocol.

I suspect I could remove the environment variable and configure all the parameters manually, but this seems a shame when the built-in behaviour is so very close to what I need!

Any advice warmly received - many thanks!

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 15, 2022

Hi there,

As this is an already existing MySQL cluster, what you could do is define a new environment variable with the correct connection string:

DATABASE_URL_MYSQL2 =  mysql2://your_cluster_details

That way you can use have better control over the environment variable and the protocol defined.

Let me know how it goes!