Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Debbi

macrumors newbie
Original poster
Nov 13, 2010
2
0
I've been researching the problem all day and need some help.

WordPress can't connect to the MySQL DB.

1) I installed MySQL via the package from MySQL.com (64-bit)
2) /etc/my.cnf shows that socket is at /var/mysql/mysql.sock
3) I check and there is no socket at /tmp/mysql.sock (does not exist)
4) My php.ini file in /etc/php.ini has "msqli.default_socket = /var/mysql/mysql.sock

I've tried to set wp-config.php to:

define('DB_HOST', 'localhost');

also tried:

define('DB_HOST, 'localhost:/var/mysql/mysql.sock');

When loading the wordpress site, I get the:

Error establishing a database connection

I confirmed the username, dbname and password with Querious

Any ideas?
 

xboxphanatic

macrumors member
Apr 29, 2010
66
37
Utah
I just recently moved my wordpress install to Leopard server. I'm just using the built in mysql service that comes with the OS. For php I used this build which includes many of the more common modules.

That setup seems to be working fine for me, but the MAMP install mentioned above might be a little easier to get going.
 

Debbi

macrumors newbie
Original poster
Nov 13, 2010
2
0
Solved

Okay, so there were 2 problems:

1) I must have edited the wrong php.ini file. I found the command "php --ri mysql" which listed all the config settings for MySQL. I found that I was pointing to /tmp/mysql.sock instead of /var/mysql/mysql.sock. A quick edit to /etc/myphp.ini fixed this (changed /tmp in 2 locations to /var/mysql)

2) Second problem. Password for my wordpress account wasn't correct in wp-config.php. I changed it to match and that fixed it all.

So it was really user error. Snow Leopard and new MySQL installs put the socket at /var/mysql/mysql.sock instead of the old location of /tmp/mysql.sock (for some kind of security reasons). Both PHP and wordpress need to know about this to work properly. The real key was finding out about the "php --ri mysql" command, which quickly let me debug things.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.