Cannot connect to Digital Ocean Managed Database from Rails Application

Hello, I’m trying to connect to one of our managed databases from the rails application with no luck after trying almost every option out there.

I can successfully connect using the flag string: mysql -u doadmin -pPASSWORD -h -P 25060 -D defaultdb

I have tried both doadmin user as well as other users or datbases. I have tried connecting via the database.yml file with either db url or db details. I have also tried with and without SSL in my database.yml file.

All options give me the same error:

01 rake aborted!
01 Mysql2::Error::ConnectionError: SSL connection error: unknown error number
01 /home/ordering/public_html/reactive_ordering/production/shared/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `connect'
01 /home/ordering/public_html/reactive_ordering/production/shared/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `initialize'

Here is an example of my database.yml file

default: &default
  adapter: mysql2
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 20 } %>
  timeout: 1000
  encoding: utf8
  sslmode: require
  sslca: <%= Rails.root.join("config/MY-DB.crt") %> 

  <<: *default
  # With connection string
  # url: <%= ENV["DATABASE_URL"] %>

  database: <%= ENV["DATABASE_NAME"] %>
  username: <%= ENV["DATABASE_USERNAME"] %>
  password: <%= ENV["DATABASE_PASSWORD"] %>
  host: <%= ENV["DATABASE_HOST"] %>
  port: 25060

Any help would be much appreciated. Thank you

Submit an answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi! I am having exactly the same issue. I’ve spent a few hours already and I haven’t managed to use DO MySQL yet. Have you found a solution in the meantime? Thanks!