[RUBY] Rails DB PostgreSQL changed to MySQL

Introduction

Until now, the database was deployed to heroku using PostgreSQL, but with heroku, a mysterious phenomenon occurs in which the posted image disappears after a certain period of time.

That's why I wanted to deploy to AWS and changed the database to MySQL, so I will try it.

MySQL

If you have already installed MySQL, please install it.

Now add gem'mysql2' to your Gemfile.

config/databese.yml


default: &default
  adapter: mysql2
  encoding: utf8
  username: root
  password:

Open database.yml and rewrite it.

If you installed it for the time being when learning some teaching materials like me, you probably have not set a password as the root user, so add ʻusername: root and password: `at this time. ..

If you have already created a user and want to log in, you should enter that username and password. (maybe)

$ bundle install

Install it.

$ bundle exec rake db:create

Create a database

$ rails db:migrate

Don't forget this command!

When I actually tried it, it wasn't particularly difficult, but I thought that if I didn't understand it, I might be addicted to it. (Because I was addicted to it)

From a beginner's point of view, changing the DB seemed difficult, but it was unexpectedly smooth, so it's important to take on the challenge!

Recommended Posts

Rails DB PostgreSQL changed to MySQL
[Rails MySQL] How to reset DB on heroku
Rails new fails to install mysql
[rails] How to display db information
Change DB from SQLite to MySQL
[Rails] Reflection to db using seeds.rb
[Rails / Heroku / MySQL] How to reset the DB of Rails application on Heroku
How to use MySQL in Rails tutorial
rails db: 〇〇 Summary
[Rails] rails new to create a database with PostgreSQL
The code I used to connect Rails 3 to PostgreSQL 10
Error deploying rails5 + Mysql to heroku with Docker-compose
[Rails] How to use PostgreSQL in Vagrant environment
SQL to get the schema list (Oracle / MySQL / PostgreSQL / SQLServer / Cassandra)
Change from SQLite3 to PostgreSQL
Change DB from SQLite to MySQL
Rails DB PostgreSQL changed to MySQL
Introducing CircleCI to Rails
Introducing Bootstrap to Rails 5
Introducing Bootstrap to Rails !!
[Java] Connect to MySQL
Introduce Vue.js to Rails
rails db: migrate failed!
[Rails] rails db command summary
How to uninstall Rails
[Rails] Development with MySQL
How to install MySQL
[Ruby on Rails] From MySQL construction to database change
What to check when rails db: migration does not pass
# What to do if you accidentally do rails db: migrate: drop
How to specify db when creating an app with rails
[rails] How to post images
rails test db only drop
[Docker] How to back up and restore the DB data of Rails application on docker-compose [MySQL]
Rails6 (MySQL, Ubuntu environment, Cloud9)
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
Connect from Java to PostgreSQL
Error in rails db: migrate
How to use rails join
Connect to DB with Java
[Rails] Add column to devise
How to terminate rails server
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
Pass parameters to Rails link_to
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
[Rails] How to make seed
[Android] Connect to MySQL (unfinished)
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
Introduced gRPC client to rails
Introduction to RSpec-Everyday Rails Summary-
[Rails] How to use Scope
[Rails] How to execute "rails db: create" etc. in production environment EC2
[PostgreSQL] If you want to delete the Rails app, delete the database first!
[Rails] What to do if data is not registered in DB
Super beginner builds Rails6 + Postgresql environment with Docker to the end
[Rails] DB settings and operations (mysql), Rubocop in VSCode, useful extensions