0

ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
Rails 5.0.0.1
Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu)

database.yml

default: &default  
adapter: mysql2  
encoding: utf8  
pool: 5   
username: ****  
password: ****  
socket: /var/run/mysqld/mysqld.sock    

When I open the page with entities it works good, but when I am trying to add new record the error appeares:
Puma caught this error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Mysql2::Error)
/home/ruby/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.4/lib/mysql2/client.rb:87:in connect
/home/ruby/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.4/lib/mysql2/client.rb:87:in initialize

After I put rails server command it works again until I try to add new record. How could I fix this bug?

  • hello, what is the output of `mysqladmin -u root status`? – Bohdan Apr 24 '17 at 05:21
  • mysqladmin -u root status -p Enter password: Uptime: 10017 Threads: 1 Questions: 6 Slow queries: 0 Opens: 107 Flush tables: 1 Open tables: 26 Queries per second avg: 0.000 – ilyas July Apr 24 '17 at 08:07
  • have you tried suggestions from http://stackoverflow.com/questions/5499035/ruby-on-rails-3-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-s? – Bohdan Apr 24 '17 at 12:11
  • First of all, it didn't help – ilyas July Apr 24 '17 at 19:17

1 Answers1

0

This solves it:

ps -A|grep mysql

sudo pkill mysql

ps -A|grep mysqld

sudo pkill mysqld

sudo service mysql restart
Paul Roub
  • 36,322
  • 27
  • 84
  • 93