Ruby on Rails 5.2.0 Mysql2::Error::ConnectionError SSL connection error: unknown error number

Viewed 1690

I am new to RoR, but not new to web development in general. I am trying to switch a Rails app from sqlite3 to mysql2, it is api-only. Added the gem to Gemfile, used bundle install, everything fine. I run rails server and see the error bellow: https://imgur.com/c4Qqf1k

This is my Database.yml:

default: &default
  adapter: mysql2
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  encoding: utf8
  reconnect: true
  host: 127.0.0.1
  port: 3306
  username: root
  password: 123456
  socket: /tmp/mysql.sock

development:
  <<: *default
  database: beginner_dev

test:
  <<: *default
  database: beginner_test

production:
  <<: *default
  database: beginner_prod
2 Answers

I succeeded to solve the problem by adding the following lines to database.yml, default section:

ssl_mode: :disabled
sslverify: false

The error isn't so descriptive, but apparently it was related to ssl.

Replace your database.yml content with the following configs

default: &default
  adapter: mysql2
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  encoding: utf8
  reconnect: true
  host: 127.0.0.1
  port: 3306
  username: root
  password: 123456

development:
  <<: *default
  database: beginner_dev

test:
  <<: *default
  database: beginner_test

production:
  <<: *default
  database: beginner_prod
Related