user2921294
user2921294

Reputation: 13

SQLSTATE[HY000][2002] Connection Error with Doctrine2

I'm using Symfony 2.3 with Doctrine2, Xampp 1.8.2 with PHP 5.4.19 on a Windows7 machine. I got that connection error with "Could not create database for connection named 'symfony'"when I try to create a DB using the command.

$ php app/console doctrine:database:create

The settings should be ok. This is my parameters.yml file.

parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_name: symfony
database_port: '3306'
database_user: root
database_password: xxx
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt

My phpMyAdmin runs correctly and I can connect any DB by simple .php files but not from Doctrine. pdo_mysql is also enabled in my php.ini. The other posts says, that the Path of the mysql.sock was wrong or that the port didn't match. In my case the Port is correct and I use 127.0.0.1 instead localhost what also was mentioned as wrong in some cases.

Hope someone can help, Pete

Upvotes: 1

Views: 1117

Answers (1)

Ema.jar
Ema.jar

Reputation: 2434

Try to change the default port if you are using MAMP.

I had the same problem because I was using the default port 3306 while i was on MAMP for which the default port number is 8889.

You can read here comments of other people with your same problem: https://stackoverflow.com/a/25107301/2649618

Upvotes: 1

Related Questions