[RAILS] MySql connection error

After rails s, I often get mysql errors, so I'd like to think about it.

Image from Gyazo

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

The meaning of the error statement is that there is no communication mechanism called a socket that connects the client and the server, so you cannot connect to the MySQL server through'/tmp/mysql.sock'.

approach

$ sudo mysql.server restart
Starting MySQL
.. SUCCESS!

Basically, it can be solved with sudo mysql.server restart

The probable cause is that the Mysql server is not started.

Referenced site

http://www.hi-ho.ne.jp/tsumiki/book_sup2.html

Recommended Posts

MySql connection error
[Docker] Connection with MySQL
Resolve Mysql2 :: Error :: ConnectionError
[Template] MySQL connection with Java
Error in Spring database connection
Mysql2 :: Error: Table'relationships' already exists
JDBC connection with MySQL 8.x * Notes *
(Solution) Mysql2 :: Error: Table'users' already exists
tomcat error
Deployment error
Error memorandum
[Deployment error] Mysql2 :: Error: Table'~' already exists: CREATE TABLE `~`
FindBugs-IDEA error
[rails s error] md5.bundle and mysql installation error
Dealing with Mysql2 :: Error: Incorrect string value error
Errors on MySQL connection CommunicationsException: Communications link failure
Error deploying rails5 + Mysql to heroku with Docker-compose
DataSource connection from WebSphere to MySQL (DataSource property change?)
MySQL error in Spring Unknown column'Value 1'in'field list'