Category Archives: Mac

After MySQL upgrade on OS X, all tables are missing

When upgrading MySQL on OS X (anno domini 2010),  I learned the hard way that the “data” folder containing your databases and tables does not get moved. Look into /usr/local; you will probably have the old mysql-* folder there containing just the “data” folder. /usr/local/mysql is a symlink to the current MySQL installation, so move its data folder elsewhere, and put the old one in there.

PHP on Mac no longer able to connect to MySQL

It’s been a while since I did web development on my Mac, and MySQL ceased to work. Could be related to that one time that I accidentally removed a bunch of dot-files from my home directory, could be related to MySQL upgrade. In any case, it no longer worked.
What I figured out was that the /var/mysql/mysql.sock UNIX domain socket was no longer generated. The /var/mysql folder was missing. When just creating it and assigning it to user _mysql (chown _mysql /var/mysql) did not help, I knew something was wrong with configuration.

MySQL tries to read configuration from /etc/my.cnf. To get its UNIX domain socket where PHP expects it, this needs to be contained in this configuration file:

[client]
port = 3306
socket = /var/mysql/mysql.sock


[mysqld]
port = 3306
basedir = /usr/local/mysql/
socket = /var/mysql/mysql.sock
; datadir = /servers/raiddrive/databases/

Please read the manual for details, and this is not administration advice; I’m not sure if this opens security holes, but I only use MySQL for development purposes. (Because you should know better than letting programmers near mission critical production servers.)

Testing for presence of Apple platform in C/C++/ObjC code

Are we running on an Apple platform?
#ifdef __APPLE__
#endif
Prerequisite for other tests
#ifdef __APPLE__
// let Apple define 
// various TARGET_OS_ 
// constants
#include  
#else
// not on Apple platform
#define TARGET_OS_MAC 0
#define TARGET_OS_IPHONE 0
#endif
Are we running on Mac OS X?
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
….
#endif
Are we running on an iOS device?
#if TARGET_OS_IPHONE
….
#endif
// updated on Oct13 2010, previous method was flawed. sorry everyone!

Apache 403 — one cause on Mac (and other Unixes)

Things suddenly broke, without installing web-server-related stuff, without touching apache config?

It’s probably permissions.
No really, you checked out permissions, and it looks ok. Really, “Sites” (or “public_html”) looks ok. However, the entire path needs to be fixed.

Check if each directory in full path to the file you want to serve contains at least executable permission for the web group, or “other” group. That is, on Mac this helped me:

chmod o+x /Users
chmod o+x /Users/ivucica
chmod 755 /Users/ivucica/Sites

What went wrong for me? I suspect Mac OS X 10.6’s disk check, or perhaps one other disk utility I recently used, messed up the executable permission flag of /Users/ivucica. I have no other explanation.

This tip would probably help under GNU/Linux too.

Steam Mac: Proxy error when accepting gifts

Getting the following error on Steam Mac when attempting to accept gift by clicking on link in the email?

Unable to connect to HTTP Proxy. Your proxy may be misconfigured or offline. -336

Unable to connect to HTTP Proxy. Your proxy may be misconfigured or offline.

Woah! But you don’t use a proxy, do you? Solution is simple. For all your Internet connections (just to be safe), in System Preferences, disable Auto Proxy Discovery. Click on screenshots to enlarge.

This worked for me, but your mileage may vary. Now, let’s report this on the Steam Mac forum…

Microphone does not work in Steam on Macbook under Windows

Looks like the drivers for Cirrus Logic audio card in unibody Macbook from late 2009 (also known as MacBook 6,1) are a bit broken. This is on Windows XP. I’m running Boot Camp 3.0 because 3.1’s installer crashes. Anyways, microphone in Steam and Steam edition of Torchlight just didn’t work. From certain posts on Apple forums, this seems to affect other software — Windows Live Messenger, et al.

Henry Wong has hacked the drivers for Macbook Pro for Cirrus Logic 4602A, and got this to work. Grab the fixed drivers from their site. 
Despite being for MBP, this seems to work on my unibody Macbook as well. This advice is offered without any guarantee it’ll work and it’s definitely not supported by Apple, so be careful.
PS Post 200!


Edit April 25th 2010:
Mirror of fixes: regular fix, no s/pdif out fix

Edit May 7th 2010:
After using these patches for some time in L4D2 and elsewhere, I conclude that one or both of the fixed drivers are breaking stereo support, to a certain extent. That is, apparently the “rear” speaker or even the microphone becomes the “left” speaker. YMMV.