Recently I tried to change the database of my Rails application. I was using sqlite3 and I wanted to change it to MySQL. I followed the steps of this tutorial : https://guides.rubyonrails.org/configuring.html#configuring-a-mysql-or-mariadb-database
This is my database.yml :
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
adapter: mysql2
encoding: utf8mb4
database: blog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
adapter: mysql2
advisory_locks: false
What caused this following error : Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) and what I need to do to fix it ?