Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
779 views
in Technique[技术] by (71.8m points)

pdo - Symfony 2 SQLSTATE[HY000] [2002] Connection refused Error

I get an error like database operations using Symfony2.

SQLSTATE[HY000] [2002] Connection refused

parameters.yml

parameters:
  database_driver: pdo_mysql
  database_host: 127.0.0.1
  database_port: '8889'
  database_name: symfony
  database_user: root
  database_password: root
  mailer_transport: smtp
  mailer_host: 127.0.0.1
  mailer_user: null
  mailer_password: null
  locale: tr
  secret: ef9b4381fe75208f060b7c786951242bebcfb3c2
  database_path: /private/var/mysql/mysql.sock

And console:

Kemal-Karakass-MacBook-Pro:~ kemalkarakas$ locate mysql.sock
/private/var/mysql/mysql.sock

How do I resolve the error?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

i had the same issue and fixed it changing

database_host: 127.0.0.1

to

database_host: localhost

in parameters.yml

hopefully this helps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...