Getting an PDO error when trying to do
php symfony doctrine:insert-sql
The error I get:
Warning: PDO::__construct(): [2002] Connection refused (trying to connect via tcp://127.0.0.1:3306) in /Users/johannes/Programmering/PHP/htdocs/symfony/sfprojects/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 470
databases.yml
all: doctrine: class: sfDoctrineDatabase param: dsn: mysql:host=127.0.0.1;dbname=jobeet; username: root password: root
Doing a mysql -u root -p jobeet
with "root" as password gives me access, so no problem there. And yes, the mysql that I run is MAMP's.
Thanks for any help.
I had the same error when attempting to build my tables in Symfony and using MAMP. I fixed the issue by changing my dsn line, in the databases.yml file, to the following:
Looks right. Here would be the exact equivalent from a working databases.yml I'm using, in case it's of any use:
MAMP PRO 2.x
I was able to solve this and many similar issues by simply unchecking "Allow local access only" in the MySQL prefs on the MAMP control panel.
MAMP PRO 3.x
As stated by Kendrick:
MAMP by default doesn't allow TCP connections. You can either turn it on or use sockets.
Changing your dsn as @Tom suggests should fix your issues. Weird as it is but using localhost instead of 127.0.0.1 makes that mysql connects through sockets.
http://dev.mysql.com/doc/refman/5.0/en/connecting.html :