Om3ga
Om3ga

Reputation: 32833

Cannot connect to mysql server Error: mysqld.sock' (38)

Hi I am working on ruby on rails project. after setting up all environment for the project but when I run localhost:3000 on my web browser it gives my this error

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (38)

Can someone help me how can I solve this problem?

Upvotes: 0

Views: 514

Answers (2)

Mate Solymosi
Mate Solymosi

Reputation: 5967

Rails by default tries to connect to MySQL using a socket file. You probably want it to connect using a TCP connection.

Check your database.yml; it should look similar to this:

development:
  adapter: mysql2
  encoding: utf8
  reconnect: true
  host: localhost
  database: {database name}
  pool: 5
  username: {username}
  password: {password}

Notice the host parameter and the missing socket parameter.

Upvotes: 1

revolver
revolver

Reputation: 2405

Check if mysql is running

mysqladmin -u root -p status

Upvotes: 2

Related Questions