質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

3回答

1436閲覧

Capistranoデプロイ時、Access deniedエラー

keisuke-kk

総合スコア0

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2020/07/31 11:03

前提・実現したいこと

個人開発アプリのデプロイ作業にて、Capistranoの導入を行なっております。
一通りのコーディングを実装後、deproyコマンド時以下のようなエラーが発生したため、
解消したいです。

発生している問題・エラーメッセージ

Mysql2::Error::ConnectionError: Access denied for user 'growool'@'localhost' (using password: NO)

該当のソースコード

database.yml

<% require 'settings' %> default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: socket: /tmp/mysql.sock host: localhost development: <<: *default database: growool_development test: <<: *default database: growool_test production: adapter: mysql2 encoding: utf8 pool: 5 database: growool_production username: <%= mysql.database_name %> password: <%= mysql.database_password %> socket: /var/lib/mysql/mysql.sock host: localhost

deploy.rb

lock "~> 3.14.0" set :application, "growool" set :repo_url, "git@github.com:keisuke-kk/growool.git" # set :branch, 'master' # Default branch is :master # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp # Default deploy_to directory is /var/www/my_app_name set :deploy_to, "/var/www/rails/growool" set :linked_files, fetch(:linked_files, []).push('config/master.key') set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') set :keep_releases, 5 set :rbenv_ruby, '2.5.1' set :log_level, :debug set :bundle_flags, '--quiet' set :bundle_path, nil set :bundle_without, nil namespace :deploy do desc 'Restart application' task :restart do invoke 'unicorn:restart' end desc 'Create database' task :db_create do on roles(:db) do |host| with rails_env: fetch(:rails_env) do within current_path do execute :bundle, :exec, :rake, 'db:create' end end end end desc 'Run seed' task :seed do on roles(:app) do with rails_env: fetch(:rails_env) do within current_path do execute :bundle, :exec, :rake, 'db:seed' end end end end desc 'Config bundler' task :config_bundler do on roles(/.*/) do within release_path do execute :bundle, :config, '--local deployment true' execute :bundle, :config, '--local without "development test"' execute :bundle, :config, "--local path #{shared_path.join('bundle')}" end end end after :publishing, :restart after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do end end end before 'bundler:install', 'deploy:config_bundler'

capfile

require "capistrano/setup" require "capistrano/deploy" require "capistrano/scm/git" install_plugin Capistrano::SCM::Git require 'capistrano/setup' require 'capistrano/deploy' require 'capistrano/rbenv' require 'capistrano/bundler' require 'capistrano/rails/assets' require 'capistrano/rails/migrations' Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

gemfile

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.4', '>= 5.2.4.3' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4', '< 0.6.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :production, :staging do gem 'unicorn' end group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'pry-rails' gem 'capistrano' gem 'capistrano-bundler' gem 'capistrano-rails' gem 'capistrano-rbenv' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' gem 'pry-byebug' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'compass-rails', github: 'Compass/compass-rails' gem 'sprockets' gem 'devise' gem 'ed25519' gem 'bcrypt_pbkdf' gem 'settingslogic'

application.yml

production: mysql: database_name: ####### database_password: ####### secret_key_base: ################################### development: test:

試したこと

・database.ymlにusernameとpasswordを直接書き込んでみました。
エラー内容より、変数にパスワードがうまく適用されていないのではないかと考えたからです。
・EC2にも、localのdatabase.yml等のファイルの内容を書き込みました。
デプロイ時に参照しているのではないかと考えたからです。

補足情報(FW/ツールのバージョンなど)

mysqlのバージョンEC2とlocalの両方で5.7を使用しております。
しかし、アプリケーションの作成時は5.6を使用しており、デプロイ作業の途中で良かれと思い、5.7にアップグレードしました。
そのせいか,
localでrails db:createを実行すると以下のエラーが発生致します。

LoadError: dlopen(/Users/kandakeisuke/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/mysql@5.6/lib/libmysqlclient.18.dylib

ご教示頂けますと、幸いです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

設定を色々いじっておりましたので、デプロイ作業を1からやり直してみます。
次は別のやり方でデプロイ作業に取り組みたいと思います。

投稿2020/08/02 03:00

keisuke-kk

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

設定を色々いじっておりましたので、デプロイ作業を1からやり直してみます。
次は別のやり方でデプロイ作業に取り組みたいと思います。

投稿2020/08/02 02:10

keisuke-kk

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

自己解決

設定を色々いじっておりましたので、デプロイ作業を1からやり直してみます。

投稿2020/08/02 02:08

keisuke-kk

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問