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