0

I have a Rails application which has a huge database. It uses the gem mysql2 to connect to MySQL. It was working fine until yesterday. Today when I started the application I am getting these errors while trying to connect to that specific database.

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR: 
Can't connect to the server

Mysql connection is established to other databases well but not to this one database. It was perfectly fine even with this database until yesterday. Why did it change suddenly?

I also checked and made changes as per the answer in this link: MySQL error 2006: mysql server has gone away but I am still getting the same error. How can I rectify this error?

Lax_Sam
  • 1,099
  • 2
  • 14
  • 32
  • Probably system mysql has crashed. try to login your mysql – Anand May 16 '19 at 05:53
  • I logged into `mysql` and checked it. When I `use some_other_database` it works fine but when I `use this_database` I get the above error. After that I cannot `use some_other_database`, it shows the same error. I should logout of mysql and then login again to `use some_other_database`. – Lax_Sam May 16 '19 at 05:56
  • Did you check mysql logs? Looks like database is damaged or you're hitting some mysql bug – Vasfed May 16 '19 at 10:20
  • Yes. I checked `error.log` file. It showed database is corrupted. I could not delete database from the usual sql command. I had to delete the database folder manually and then again ran `bin/rake db:setup`. But why did it happen like that? I did not change anything in the code or database. – Lax_Sam May 16 '19 at 11:26

0 Answers0