Ruby in Rails 4をcentosに入れて、bundle exec rails s -b 0.0.0.0
で起動させて、
ブラウザからアクセスしたところ「ActiveRecord::ConnectionNotEstablished」とエラーが表示されてしまいました。
mysqlでの接続を想定していまして、
centosにmysqlは入れております。データベースも作成済みです。
環境や設定ファイルは下記のようになっています。
環境
- centos 6.7
- msyql 5.7.18
- ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
- rails 4.2.9
設定ファイル
- Gemfile
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.9' # Use sqlite3 as the database for Active Record # gem 'sqlite3' gem 'mysql2' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.1.0' # See https://github.com/rails/execjs#readme for more supported runtimes gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' # gem 'therubyracer', platforms: :ruby end
- config/database.yml
database.yml
1# SQLite version 3.x 2# gem install sqlite3 3# 4# Ensure the SQLite 3 gem is defined in your Gemfile 5# gem 'sqlite3' 6# 7default: &default 8 adapter: mysql2 9 encoding: utf8 10 database: db_name 11 pool: 5 12 username: root 13 password: 14 socket: /tmp/mysql.sock 15 16development: 17 <<: *default 18# database: db/development.sqlite3 19 20# Warning: The database defined as "test" will be erased and 21# re-generated from your development database when you run "rake". 22# Do not set this db to the same as development or production. 23test: 24 <<: *default 25# database: db/test.sqlite3 26 27production: 28 <<: *default 29# database: db/production.sqlite3 30
何か原因等わかる方がいらっしゃいましたら、
ご教授いただけますでしょうか。
あなたの回答
tips
プレビュー