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.
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 :
On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port or -P option is given to specify a port number. To ensure that the client makes a TCP/IP connection to the local server, use --host or -h to specify a host name value of 127.0.0.1, or the IP address or name of the local server. You can also specify the connection protocol explicitly, even for localhost, by using the --protocol=TCP option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With