Reputation: 25
I am trying to connect my database with MySQL, but I have the following error:
[Doctrine \ DBAL \ Exception \ ConnectionException] An exception occured in driver: SQLSTATE [HY000] [2002] Connection refused
I have my project in the following path (I'm using OS X Capitan): /Applications/ XAMPP/htdocs/Projects/Cupon
. I'm trying to complete the get and set methods automatically with the command: php app/console doctrine:generate:entities TiendaBundle
.
Class code (Project/Cupon/src/Cupon/TiendaBundle/Entity/Tienda.php):
<?php
namespace Cupon\TiendaBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/** @ORM\Entity */
class Tienda
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*/
protected $id;
/** @ORM\Column(type="string", length=100) */
protected $nombre;
/** @ORM\Column(type="string", length=100) */
protected $slug;
/** @ORM\Column(type="string", length=10) */
protected $login;
/** @ORM\Column(type="string", length=255) */
protected $password;
/** @ORM\Column(type="string", length=255) */
protected $salt;
/** @ORM\Column(type="text") */
protected $descripcion;
/** @ORM\Column(type="text") */
protected $direccion;
/**
* @ORM\ManyToOne(targetEntity="Cupon\CiudadBundle\Entity\Ciudad")
* @ORM\JoinColumn(name="ciudad_id", referencedColumnName="id")
*/
protected $ciudad;
}
I have a database called "symfony" in MySQL (XAMPP 5.6.3) and my configuration file in Symfony is as follows:
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symfony
database_user: root
database_password: '123'
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: c11eccf2a788b331cb9548ff4106c7461
I don't know how I can connect my project Symfony with my database in phpmyadmin.
Upvotes: 2
Views: 5525
Reputation: 36
I hope you have your problem already solved, if not my solution may help you.
I had a very similar problem, but I was using MAMP, I solved my problem changing the configuration of the pdo_mysql.default_socket
in the /etc/php.ini
.
Why? I used terminal to create the database with
php app/console doctrine:database:create
and I use MAMP to test the site.
So, the problem, terminal was using a diferent pdo_mysql.default_socket
than MAMP.
MAMP uses the config from
/Applications/MAMP/bin/php/php5.3.6/conf/php.ini
and terminal use the
/etc/php.ini
My solution:
change in my /etc/php.ini
the line
pdo_mysql.default_socket=/var/mysql/mysql.sock
with:
pdo_mysql.default_socket=/Applications/MAMP/tmp/mysql/mysql.sock
Also I change my default zone:
date.timezone = "Europe/Bucharest"
I hope, this could help you doing something simmilar but now using your XAMMP socket.
Sorry for my English.
Upvotes: 2