I created a "Hello World" Rails app as per the instructions here, with the exception that my Rails version is 5.2.4.4 and my database is MySQL:
~/Workspace/project_time/mysql/foobar (master) $ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
~/Workspace/project_time/mysql/foobar (master) $ rails -v
Rails 5.2.4.4
~/Workspace/project_time/mysql/foobar (master) $ rails new foobar -d mysql
My Gemfile specifies the correct version of Ruby:
ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.4', '>= 5.2.4.4'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
After a successful git push heroku master
, I subsequently ran heroku addons:create cleardb:ignite
and did not see any errors.
I also ran the provisioning instructions which I found here, including setting up the DATABASE_URL
env var. I confirmed that both this env var and the CLEARDB_
-prefixed version of same appear as follows:
mysql://<cleardb_username>:<cleardb_pwd>@us-cdbr-east-03.cleardb.com/<heroku_path>?reconnect=true
And I added the following to my database.yml file:
production:
url: <%= ENV['DATABASE_URL'] %>
Also in database.yml, I verified that the default adapter is set up as follows, and that my production settings don't perform an override:
default: &default
adapter: mysql2
Now, I'm trying to run heroku run rake db:setup
, however I'm seeing the following error:
rake aborted!
LoadError: Could not load the 'mysql' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile.
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'
......
Caused by:
LoadError: cannot load such file -- active_record/connection_adapters/mysql_adapter
Per this link, I saw that one suggested change is to update the protocol used for DATABASE_URL
from mysql://
to mysql2://
. I tried this, without success. The error I get in this case is:
Mysql2::Error::ConnectionError: SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
Suggestions?
EDIT: I also tried making the same mysql2://
change to the CLEARDB_DATABASE_URL
env var, but that had no effect and I still observed the same cannot load such file
error.
question from:
https://stackoverflow.com/questions/65892659/rails-app-w-mysql-on-heroku-cleardb-cannot-load-such-file-active-record