PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 16, 2022

[FIXED] Symfony 2: [PDOException] SQLSTATE[HY000] [2002] Connection refused entity generator

 March 16, 2022     connection-refused, doctrine, entity, mamp, symfony     No comments   

Issue

Recently I started working with Symfony. I created a project with the terminal/composer under the name "symfony" and also created a database on phpmyadmin (MAMP) which I called "symfony". I installed the project, and except a error of my timezone, my project was succesfully created and was running at my localhost.

After that I created a bundle called "SymfonyCinemaBundle" and my bundle was generated succesfully. I also tried to generate a entity but that is not working for me, and also the problem. After I open up the generator with the command, It asks for a shortcut name and I tried to use "SymfonyCinemaBundle:Movie" but that isn't working and gives me the following error:

*The Entity shortcut name: SymfonyCinemaBundle:Movie

[Doctrine\DBAL\Exception\ConnectionException]                              
  An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused  


  [Doctrine\DBAL\Driver\PDOException]        
  SQLSTATE[HY000] [2002] Connection refused  


  [PDOException]                             
  SQLSTATE[HY000] [2002] Connection refused  

doctrine:generate:entity [--entity ENTITY] [--fields FIELDS] [--format FORMAT] [--with-repository]*

I checked my parameters.yml but thats seems to be right. I've looked on the internet but nothing seems to help unfortunately. Does anyone has a solution for me?

Note: I'm using MAMP. The difference between normal and developers mode has no difference.


Solution

Solved:

I've changed the host in parameters.yml to localhost instead of 127.0.0.1. I also added the right port number (normally it doesn't matter) and that solves the problem but has given me another error instead: "No such file or directy". It had to do with my mysql.sock so I used the following commands in my terminal:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
sudo chown _mysql /var/mysql/mysql.sock
sudo chmod 777 /var/mysql/mysql.sock


Answered By - Giesburts
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing