Matt Langtree

Tag: Aluminium iMac

Leopard/Snow Leopard - mysql_connect() Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2)

by matt on Jul.05, 2009, under Mac OS X Hints

I was setting up my local PHP/MySQL development environment on my local MacBook Pro to mirror our work development setup.

I ran into the following error:

Warning on line 365 of include/lib/adodb/drivers/adodb-mysql.inc.php mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2)

I have fixed this issue in the past on a previous Leopard install, so I thought it was the perfect candidate for a blog post.

Customise php.ini file to use custom MySQL socket

If you have made manual customisations to your php config file already, skip this part; otherwise run the following in Terminal.app:

sudo cp /etc/php.ini.default /etc/php.ini

Next, open Sequel Pro and connect to the mysql server on your local Mac. If you don’t know how to do this, take a look at Getting Connected on the Sequel Pro documentation page.

Then, choose Database > Show Server Variables…

show-server-variables

Scroll down through the list of variables until you get to socket.

screenshot-on-2009-07-05-at-24810-pm

Open up /etc/php.ini in Textmate or Coda and scroll down the where it says:

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =

Change the mysql.default_socket line to read:

mysql.default_socket = /tmp/mysql.sock

Restart Web Sharing Service (Apache)

Now, restart your Web Sharing service by going to  > System Preferences

Choose Sharing from the System Preferences page.

sharing-page

On the sharing pane, uncheck Web Sharing, wait a second for it to do its thing, then recheck it. If it was already unchecked, you will just need to choose the checkbox once.

screenshot-on-2009-07-05-at-30027-pm

Now, just reload your php page in Safari, and it should hopefully just work. Your app should now be connecting to the local MySQL server on your Mac. Enjoy!

1 Comment :, , , , more...

One for the Mac Guys

by Matt on May.17, 2008, under Rantings

The recent charity dinner for Lead On Cairns that I helped out at, was quite a success.

The night was kept running smoothly by 4 Macs. Two of the macs (an iBook and either a MacBook Pro or a PowerBook) were being run by the sound/lighting guys.
Apple iMac 20\" and Apple iMac 24\"

We had a 24″ Aluminium iMac [in the middle of the room] feeding the projector with the great Keynote presentation that I worked on. The keynote presentation on the 24″ iMac was also being controlled by the Apple Remote from the presenters lectern.

I also had my 20″ Aluminium 2.4Ghz iMac [at the back of the room] to use as preparation for my speech. I decided that I would set up an ad-hoc wireless network to send any last minute changes up to the 24″ iMac. Instead of walking back and forth to close and open Keynote.app I set up “Screen Sharing” on the 24″ iMac, and connected to the projector machine from my iMac.

As a side-effect of this setup, I decided to remotely control the slide from MY iMac as a failsafe if the remote didn’t work properly

This method of controlling the presentation proved to be quite successful, considering some of the guest speakers had multiple slides.

For more information about the Lead On Cairns Community Dinner visit leadoncairns.com.au.

1 Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...