0
votes

I'm totally confused here. I have MAMP on an iMac it says MySQL is running. When I try access it via Sequel Pro I can connect using the socket option

enter image description here

However if I try to connect using the Standard method I get a 'connection refused'

**enter image description here**

enter image description here

When I try connect with PHP I get the connection refused message

$db = new PDO("mysql:host=127.0.0.1:8889;dbname=wabie_centraldb", "root", "root", array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode=""') );

I'm confused because obviously mysql is running (because I can connect one way).

I have the same setup on my MacBook and it all works perfectly

Any suggestions?

Many Thanks!

1

1 Answers

1
votes

The standard port for MySQL is 3306 and does not need to be specified in the connection:

$db = new PDO("mysql:host=127.0.0.1;dbname=wabie_centraldb", "root", "root", array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode=""') );

To specify a database connection port use the following DSN string:

$db = new PDO("mysql:host=127.0.0.1;port=3306;dbname=wabie_centraldb", "root", "root", array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode=""') );

You can test 3306 in your Sequel Pro in your standard connection. In addition, you may have to change the host from 127.0.0.1 to localhost depending on how you're set up.