Archive for the ‘Mac OS X’ Category

Unable to connect to MySQL from PHP (on Mac OS X)

Friday, June 13th, 2008

When I tried to connect to MySQL from PHP, using mysql_connect, it gives me the “Can’t connect to MySQL through socket” error. And I am definitely sure, I added the user into MySQL, and had the correct password.

mysql_connect('localhost', 'username', 'very_encrypted_password');

The thing is, it works if I use 127.0.0.1 instead of localhost, strange..

MySQL:

$ mysql --version
mysql  Ver 14.12 Distrib 5.0.51a, for apple-darwin9.2.2 (i686) using  EditLine wrapper

PHP:

$ php --version
PHP 5.2.5 (cli) (built: Mar  4 2008 22:57:15)

After asking for help from Colin, who gave me a head start and some google’ing, I found a solution.

Quoted from the site [1]:

One problem that has come about with MySQL and Leopard is the location of the mysql.sock file. Previously, the default location for this file was in the /tmp directory. That location has now moved to the /var/mysql directory. PHP will look for it there. Unfortunately, the default location from the MySQL will still place it in the old location.

First of all, stop MySQL. Then open up /etc/my.cnf:

sudo vim /etc/my.cnf

In my case, I only had a couple of lines there:

[mysqld]
binding = 127.0.0.1

Add these line, to the appropiate headings:

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

Then, create the directories and set the proper permission:

sudo mkdir /var/mysql
sudo chown _mysql /var/mysql

Finally, restart MySQL, and try it out!

ref:

  1. Working with PHP 5 in Mac OS X 10.5 (Leopard)

2008 WWDC Keynote Aftermath

Wednesday, June 11th, 2008

I stayed up all night yesterday, just to follow the Apple WWDC Keynote by Steve Jobs.

Summarising some important points from the Keynote:

The Keynote can be found on Apple’s website, or iTunes. There is also a new iPhone 3G ads.

LaTeX on Mac OS X

Wednesday, May 28th, 2008

For those who didn’t know, I am currently completing my Honours in Bachelor of Software Engineering with Monash University. I’ll talk more about the Honours project later on.

I have been using OpenOffice 2.4 for documents writing, including my research proposal for the Honours project. It worked quite well, but I have decided to switch to LaTeX to deal with documents writing (for the thesis).

LaTeX is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing [1].

To get LaTeX up and running on my MacBook, I downloaded the MacTeX package, and the installation was pretty straightforward. The only painful part is, it took away 800MB of my internet allowance, and I think you should know that it will take around 1.6GB disk space to install.

If you’ve not worked with LaTeX before, keep in mind that:

LaTeX is not a word processor!

If you want a decent word processor on Mac OS X, TextMate is what I am using.

Last but not least, always good to have this LaTeX guide around (I’ve had it since my first year in Monash, three years later, I’m using it again): The Not So Short Introduction to LaTeX2e

ref:

  1. LaTeX project: An introduction

MySQL 5 on Mac OS X Leopard

Thursday, April 17th, 2008

Needed MySQL up and running, so I can start playing around with Rails for my Studio Project.

I have heard issues about the MySQL Package Installer, the PrefPane for one [1], but its been fixed last I heard [2]. Nevertheless, I still chose to compile MySQL by myself.

Dan Benjamin has written a very detailed guide to install MySQL on Mac OS X.

ref:

  1. MySQL Bugs: #28854
  2. MySQL on Leopard OS X 10.5 PrefPane fixed!

Thunderbird + Lightning + Provider for Google Calendar

Sunday, April 13th, 2008

Just to remind myself how to get all three of them working together - bi-directional sync between Thunderbird and Google Calendar!

  1. Download + Install Thunderbird
  2. Download + Install Lightning (version 0.8 by the time of writing)
  3. Download + Install Provider for Google Calendar (version 0.4 by the time of writing)
  4. In Google Calendar, go to Settings -> Calendars -> click on the calendar you want to import to Thunderbird.
  5. Copy the Private Address (XML)
  6. Open up Thunderbird, switch to Calendar view.
  7. Select File -> New Calendar …
  8. Choose the ‘On the Network’ option, and then select Google Calendar.
  9. Enter the Private Address you just copied.
  10. If Lightning asked you for user/pass - enter your Google user/pass.
  11. Finish up the setup by entering your calendar name, color, etc.

These are the exact same steps I took for both my Gutsy desktop and MacBook (Mac OS X Leopard).