I'm a beginner in programming and studying, but I couldn't get any information even if I googled, so I'll report it.
Mac OS X Ruby: 2.7.1 Rails: 6.0.3.4 heroku stack: heroku-20 (when an error occurs) DB: MYSQL
https://qiita.com/murakami-mm/items/9587e21fc0ed57c803d0 When I tried to deploy to heroku referring to this article,
console
$ heroku rake db:migrate
When you run
console
Mysql2::Error::ConnectionError: SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
I got an error.
There are two reasons why this error occurred in my environment
➀ heroku stack was heroku-20 ➁ There was no necessary description in config/database.yml
➀ heroku stack was heroku-20 → Make heroku-18 available
console
heroku stack:set heroku-18 -a <app name>
➁ There was no necessary description in config/database.yml Add the following code to production
config/database.yml
production:
url: <%= ENV['DATABASE_URL'] %>
We are always looking for good reasons. .. Please let me know. ..
➀ heroku stack was heroku-20 Didn't you write the necessary processing that came out by changing to heroku-20? → Solved for the time being by using heroku-18 so far
➁ There was no necessary description in config/database.yml
There seems to be such a description in config/database.yml (I disappeared for some reason)
config/database.yml
# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
Especially this time, the description in the latter half is important
config/database.yml
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
Roughly translated into Japanese
"On Heroku and other platforms, you'll get various URLs in the form of environment variables. DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" You can use this data structure like this production: url: <%= ENV['DATABASE_URL'] %>」
The point is that I didn't have this description, so I didn't know which database to use and got an error.
If something goes wrong and you don't understand even if you google, check the version of what you are using!
Thank you for reading.