起きていること、実現したいこと
下記の記事を参考にAWSへデプロイをしています。
https://qiita.com/shunsuke284052/items/26e10494ef05e56d3d01
下記の部分で「rails db:create RAILS_ENV=production」を実行したところで詰まっています。
対処方法を教えていただきたいです。
エラー内容
[ec2-user@ip-172-31-35-175 portfolio]$ rails db:create RAILS_ENV=production Mysql2::Error::ConnectionError: Access denied for user ''@'localhost' to database 'portfolio_production': CREATE DATABASE `portfolio_production` DEFAULT CHARACTER SET `utf8` Couldn't create 'portfolio_production' database. Please check your configuration. rails aborted! ActiveRecord::StatementInvalid: Mysql2::Error::ConnectionError: Access denied for user ''@'localhost' to database 'portfolio_production': CREATE DATABASE `portfolio_production` DEFAULT CHARACTER SET `utf8` bin/rails:4:in `<main>' Caused by: Mysql2::Error::ConnectionError: Access denied for user ''@'localhost' to database 'portfolio_production' bin/rails:4:in `<main>' Tasks: TOP => db:create (See full trace by running task with --trace)
新たなエラー
「rails db:migrate RAILS_ENV=production」を実行すると下記のようなエラーがでます。
[ec2-user@ip-172-31-35-175 portfolio]$ rails db:migrate RAILS_ENV=production == 20200802224225 DropTableMicroposts: migrating ============================== -- drop_table(:microposts) rails aborted! StandardError: An error has occurred, all later migrations canceled: Mysql2::Error: Unknown table 'portfolio_production.microposts': DROP TABLE `microposts` /var/www/portfolio/db/migrate/20200802224225_drop_table_microposts.rb:3:in `change' bin/rails:4:in `<main>' Caused by: ActiveRecord::StatementInvalid: Mysql2::Error: Unknown table 'portfolio_production.microposts': DROP TABLE `microposts` /var/www/portfolio/db/migrate/20200802224225_drop_table_microposts.rb:3:in `change' bin/rails:4:in `<main>' Caused by: Mysql2::Error: Unknown table 'portfolio_production.microposts' /var/www/portfolio/db/migrate/20200802224225_drop_table_microposts.rb:3:in `change' bin/rails:4:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace) [ec2-user@ip-172-31-35-175 portfolio]$ ails db:migrate RAILS_ENV=production -bash: ails: コマンドが見つかりません [ec2-user@ip-172-31-35-175 portfolio]$ rails db:migrate RAILS_ENV=production == 20200802224225 DropTableMicroposts: migrating ============================== -- drop_table(:microposts) rails aborted! StandardError: An error has occurred, all later migrations canceled: Mysql2::Error: Unknown table 'portfolio_production.microposts': DROP TABLE `microposts` /var/www/portfolio/db/migrate/20200802224225_drop_table_microposts.rb:3:in `change' bin/rails:4:in `<main>' Caused by: ActiveRecord::StatementInvalid: Mysql2::Error: Unknown table 'portfolio_production.microposts': DROP TABLE `microposts` /var/www/portfolio/db/migrate/20200802224225_drop_table_microposts.rb:3:in `change' bin/rails:4:in `<main>' Caused by: Mysql2::Error: Unknown table 'portfolio_production.microposts' /var/www/portfolio/db/migrate/20200802224225_drop_table_microposts.rb:3:in `change' bin/rails:4:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/09/21 10:40
2020/09/21 10:42
2020/09/21 15:31
2020/09/22 10:07