0

trying to install wordpress on osx mavericks (with built-in apache+php and homebrew mysql).

mysql -u root # connects
php -r 'var_dump(mysql_connect("localhost", "root", ""));' # doesn't connect

web-searching revealed that mysql connects to 'localhost' via a unix socket, but connects to loopback ip 127.0.0.1 via a network socket.

php -r 'var_dump(mysql_connect("127.0.0.1", "root", ""));' # connects!

why can't i connect to mysql via localhost from php??

soliton_zero
  • 51
  • 1
  • 1

1 Answers1

0

"web-searching revealed that mysql connects to 'localhost' via a unix socket"

Because PHP is attempting some optimization that is causing unintended effects. Your instance of MySQL is listening for connections on tcp port 3306. PHP is trying to connect to a UNIX socket on the file system.

Daniel Widrick
  • 3,418
  • 2
  • 12
  • 26