Recently I was trying to install/configure WordPress on OS X (Lion) with MySql 5.5. After reading the installation guide, I did not expect anything to go wrong, but as it goes without saying, theory is totally different from practical, I did face issue. After setting
wp-config.php, when I hit the
/wordpress/wp-admin/install.php, I got a nice page saying
Error establishing a database connection. Obvious reason for this would be (as mentioned on the error page) would be the wrong user/password or wrong host or wrong database name. I checked all parameters and none were wrong and I was also able to connect to MySQL database which I created for WordPress with MySQL WorkBench and also from mysql command line.
To verify my settings, I just created and a test php page to test if I can connect to my newly create WordPress database. I was not able to connect and got some more details about no connection. I got following wraning
ErrorException [ Warning ]: mysql_connect() [function.mysql-connect]:
[2002] No such file or directory (trying to connect via
unix:///var/mysql/mysql.sock)
Obviously when I checked
/var/mysql/mysql.sock, I could not find it. So next step was to find where is my missing
mysql.sock and found it under
/tmp. After googling a lot, I could not find any concrete solution to resolve this. Niether there is anything which I can change for MySQL configuration nor for the PHP configuration. So my last resort and the easy solution was creating a symbolic link. I just created a symbolic link on
/var/mysql to point to
/tmp (
sudo ln -s /tmp /var/mysql) and hit the refresh on WordPress installation page and everything was just smooth. Happy blogging :-)
Cheers !!!
- Jay