Friday, March 18, 2011

How to make MySQL and PHP to Communicate in Mac?

I already explained How to make PHP and Apache to Communicate  in Mac.
Now, we will do the same with MySQL and PHP.
The default location of mysql.sock is in the /tmp/mysql.sock directory. We’ll need to change this to /var/mysql/mysql.sock as this is where PHP will look for it.
So first off, create a my.conf (or in this case my.cnf) file in your text editor and save it as my.cnf in the /etc folder with the following code:

[client]
socket = /var/mysql/mysql.sock
 
[mysqld]
socket = /var/mysql/mysql.sock

Next move mysql.sock to it’s new directory by typing the following code in a Terminal window:

$ sudo mkdir /var/mysql
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

That is pretty much.

No comments: