Installing MySQL on Mac OS X over SSH
by Russ on Oct.15, 2009, under Daily Grind
Reasserting my geek credentials…
Well it’s been a while since I’ve done anything remotely technical. Even longer since I blogged about such things. So I thought I would share with you, dear reader, a small adventure I’ve just got back from.
Installing MySQL on Mac OS X over SSH
Having recently upgraded my Mac Mini to snow leopard, I was not entirely surprised to find that my old MySQL installation mysteriously vanished breaking my neat little PHP application. But, the only time I have access to said Mac is when it is in service playing DVD’s as a part of my home theater system. So, the mission is to install and configure a MySQL server on Mac OS X without interrupting the screen usage for more than two minutes (I will confess my sins as we go).
My fist sin to confess is that I like things to be easy. So I downloaded a nice Mac binary rolled into a .dmg file… on my mac book.
Of course, with file sharing already set up, it’s easy as pie to transfer my .dmg file onto the Mac Mini without interrupting anything. The next trick was to mount the .dmg file and install the MySQL binary over ssh.
Mounting a .dmg file and installing a .pkg binary over ssh
Mounting a .dmg file over ssh is fairly straightforward:
hdiutil attach mysql-5.1.39-osx10.5-x86
This mount the disk image file in /Volumes/mysql-5.1.39-osx10.5-x86 on the remote machine. The next trick is to run the installer files.
cd /Volumes/mysql-5.1.39-osx10.5-x86/ sudo installer -pkg mysql-5.1.39-osx10.5-x86.pkg
Note that you need to play the superuser role in order to install the package. Since We’re here, I’ll install the MySQL startup item as well…
sudo installer -pkg MySQLStartupItem.pkg
Happily, we now have MySQL installed and, yes, we haven’t had to mess around with the Mac UI at all yet. At this stage, I must confess, I did nip into the UI when nobody was looking and install the MySQL.prefpane into the system prefences window and then use it to start the MySQL service. Although I confess that the service could have been started over SSH by using mysqld.
So lets take stock. We’ve installed a MySQL binary from a .dmg on Mac OS X over SSH, the MySQL Daemon service is running and now we just need to make a few minor changes to the basic setup that has been installed to make things ready to reinstate my PHP application and rejoice.
After installing MySQL, the documentation says that a /tmp/mysql.sock file should be created automatically. Unfortunately, this seemed to be missing. So my next port of call was locating the naughty .sock file and creating a symbolic link in the /tmp folder where it belongs.
ln -s /var/mysql/mysql.sock /tmp
There we go. Finally, all that needs doing is running up mysql and running a few queries to set up my database, tables and permissions and I’m all done. I won’t bore you with the SQL, because it’s way past my bedtime now.
– Incidentally, I had already enabled PHP on Mac OS X’s existing Apache installation and, with the socket file linked in correctly and the databases re created and populated, everything started working again. Ain’t life grand when you discover you can do something the hard way too..?
G’Night!