I'm doing it locally Ruby v2.5.1 Rails v5.2.4 MySQL v8.0.19
After creating a rails project, I encountered this error when I tried `rails s'
Mysql2::Error::ConnectionError (Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)):
As you can see from the error statement, you can immediately tell that it is "Ah, MySQL".
Since it says ConnectionError, you can immediately tell that it is not connected.
Check out database.yml.
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
socket: /tmp/mysql.sock
---Omitted below---
The password of the yml file is missing. During this time, I forgot to set a password for MySQL.
I was able to connect even if I hadn't set it before, but it seems that it didn't connect well this time because I set it.
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: password #Postscript
socket: /tmp/mysql.sock
I feel relieved when this screen appears. Cute kids
Thank you for reading to the end. I hope it helps you even a little.
Recommended Posts