[Ruby] MySQL isn’t working as expected… Rails app isn’t running.

1 minute read

generated background

MySQL service is in error again. If it happens many times, it will be a waste of time. Below is the error content.

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

Environment

| Item | Content | |:—————–|:——————:| | OS.Catalina | v10.15.4 | | Ruby | v2.5.1 | | Ruby On Rails | v5.2.4.3 | | MySQL | v5.6 |

Procedure

[Survey 1] Is MySQL running? I’m using “Sequel Pro”, so I’ll try connecting. → Connection error

Check process operating status


CMD>ps -ef | grep mysql
  501 1287 1 0 11:45AM ?? 0:00.06 /bin/sh /usr/local/opt/[email protected]/bin/mysqld_safe --datadir=/usr/local/var/mysql
  501 6400 1287 0 11:55AM ?? 0:00.51 /usr/local/opt/[email protected]/bin/mysqld --basedir=/usr/local/opt/[email protected] --datadir=/usr/local/var /mysql --plugin-dir=/usr/local/opt/[email protected]/lib/plugin --log-error=ichikawadaisukenoMacBook-Air.local.err --pid-file=ichikawadaisukenoMacBook-Air.local.pid
  501 6402 804 0 11:55AM ttys000 0:00.01 grep mysql

!! ? Looks like it’s running! ?

[Survey 2] First, from the error content. It is said that there is no socket file, so I tried using the following command.

Try to create a socket file.


CMD> cd application folder
CMD>touch /tmp/mysql.sock

→ As a result, no improvement.

[Survey 3] Check the log.

Check the MySQL log


CMD>more /usr/local/var/mysql/ichikawadaisukenoMacBook-Air.local.err
(Partially omitted)
mysqld_safe A mysqld process already exists
  • Even after restarting after this, there is no improvement.

Correspondence

It seems that multiple processes are running. Stop existing running processes.

stop process


CMD>kill -9 Target service process

This is the only improvement this time. However, the following error message is still being output.

200616 16:04:42 mysqld_safe A mysqld process already exists

I will take action at a later date.