jyr / MNPP

Mac + Nginx + Percona + PHP a high performance web server in a one-click installer
http://getmnpp.org
314 stars 49 forks source link

"localhost" doesn't work for MySQL, only "127.0.0.1" #75

Open theDanielJLewis opened 11 years ago

theDanielJLewis commented 11 years ago

Oddly, nothing related to MySQL works when I use "localhost," as this appears to use a socket that isn't available in MNPP. (I'm not exactly sure I understand this.)

But if I use "127.0.0.1" instead of localhost, it works fine.

What's going on wrong?

I do have localhost assigned in my hosts.

marcosgdf commented 11 years ago

It's not the same localhost and 127.0.0.1 for mysql connections.

http://serverfault.com/questions/295285/mysql-cannot-connect-via-localhost-only-127-0-0-1

Daniel15 commented 11 years ago

It's because the socket filename is incorrect.

This is in the MySQL configuration:

socket          = /Applications/MNPP/tmp/mysql/mysql.sock

The path in php.ini needs to be updated to reflect this:

[mysql]
mysql.default_socket = /Applications/MNPP/tmp/mysql/mysql.sock
[mysqli]
mysqli.default_socket = /Applications/MNPP/tmp/mysql/mysql.sock
[pdo_mysql]
pdo_mysql.default_socket = /Applications/MNPP/tmp/mysql/mysql.sock
majidmushtaq91 commented 9 years ago

@Daniel15 your solution worked for me thanks.