0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Mysqlにデータベースを変更する

Last updated at Posted at 2020-09-10

database.ymlの中身を以下のように書き換えてください。

config/database.yml
default: &default
  adapter: mysql2
  encoding: utf8mb4
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password:
  socket: /tmp/mysql.sock
development:
  <<: *default
  database: amazon_app_mysql_development
test:
  <<: *default
  database: amazon_app_mysql_test
production:
  <<: *default
  database: amazon_app_mysql_production
  username: amazon_app_mysql
  password: <%= ENV['AMAZON_APP_MYSQL_DATABASE_PASSWORD'] %>

sqliteをコメントアウトする

Gemfile
#gem 'sqlite3', '~> 1.4'

mysqlを追加する

Gemfile
gem 'mysql2', '>= 0.4.4'

mysql2を更新させ、反映させる

ターミナル
$ bundle update

DBを初期化

$ rails db:migrate:reset
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?