sqliteからmysqlへ変更し、その後rails :db:createコマンドを実行しデータベースの作成を試みたところ次のようなエラーが出てしまいました。
rails db:create /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:90: warning: already initialized constant FileUtils::VERSION /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:105: warning: previous definition of VERSION was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1188: warning: already initialized constant FileUtils::Entry_::S_IF_DOOR /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1284: warning: previous definition of S_IF_DOOR was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1446: warning: already initialized constant FileUtils::Entry_::DIRECTORY_TERM /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1568: warning: previous definition of DIRECTORY_TERM was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1501: warning: already initialized constant FileUtils::OPT_TABLE /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1626: warning: previous definition of OPT_TABLE was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1555: warning: already initialized constant FileUtils::LOW_METHODS /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1685: warning: previous definition of LOW_METHODS was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1562: warning: already initialized constant FileUtils::METHODS /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1692: warning: previous definition of METHODS was here rails aborted! ActiveRecord::DatabaseConfigurations::InvalidConfigurationError: '{ default => }' is not a valid configuration. Expected '' to be a URL string or a Hash. /Users/apple/create/portfolio/Rakefile:6:in `<top (required)>' /Users/apple/create/portfolio/bin/rails:9:in `<top (required)>' /Users/apple/create/portfolio/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Caused by: Bootsnap::LoadPathCache::FallbackScan: (See full trace by running task with --trace)
また、sqliteからmysqlへ変更した際にdatabase.ymlも変更したのでそちらも載せておきます。
database.yml
1 default: &default 2 adapter: mysql2 3 encoding: utf8 4 pool: 5 5 username: root 6 password: password #<- mysqlインストール時に設定したパスワード 例: 1 7 socket: /var/lib/mysql/mysql.sock 8 9development: 10 <<: *default 11 database: アプリ名_development #アプリ名_development 12 13test: 14 <<: *default 15 database: アプリ名_test #アプリ名_test 16 17production: 18 <<: *default 19 database: アプリ名_production #アプリ名_production 20 username: アプリ名 #アプリ名 21 password: <%= ENV['TESTMYSQL_DATABASE_PASSWORD'] %> 22
database.ymlファイルのアプリ名とパスワードの部分はまだ環境変数化できていないので、伏せています。
また、mysqlのバージョンは下記に参照
mysql Ver 14.14 Distrib 5.6.47, for osx10.15 (x86_64) using EditLine wrapper
rubyとrailsのバージョンも載せておきます!
ruby --version ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin15] rails --version /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:90: warning: already initialized constant FileUtils::VERSION /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:105: warning: previous definition of VERSION was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1188: warning: already initialized constant FileUtils::Entry_::S_IF_DOOR /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1284: warning: previous definition of S_IF_DOOR was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1446: warning: already initialized constant FileUtils::Entry_::DIRECTORY_TERM /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1568: warning: previous definition of DIRECTORY_TERM was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1501: warning: already initialized constant FileUtils::OPT_TABLE /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1626: warning: previous definition of OPT_TABLE was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1555: warning: already initialized constant FileUtils::LOW_METHODS /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1685: warning: previous definition of LOW_METHODS was here /Users/apple/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fileutils.rb:1562: warning: already initialized constant FileUtils::METHODS /Users/apple/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1692: warning: previous definition of METHODS was here Rails 6.0.3
質問の確認と返信どうかよろしくお願いします!
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/06/03 08:53
2020/06/03 08:54
2020/06/03 09:02
2020/06/03 09:07 編集
2020/06/03 09:55
2020/06/03 10:05 編集
2020/06/03 10:15
2020/06/03 10:24 編集