How to restore a MySQL database from your Time Machine backup

I’m writing this as much to remind myself as for anyone else really :) I generally run databases running on my MacBook which I use for sites in active development, I then transfer these databases over to a staging server which are then use by other people in the team and sometimes clients to input site content. Last week I imported content from the staging server and overwrote my local database thinking that the staging server was the most up to date, but as it turned out I was incorrect!

Fortunately I’m running Mac OS X’s Time Machine backup on my MacBook so I didn’t see a problem as I could just restore it from that. However, in reality it wasn’t quite as straight forward to do, so here’s what I had to do in the end to restore this database from my Time Machine backup.

Step 1: Find your local databases

Navigate to the location of your MySQL databases. For my MySQL install this is found at /usr/local/mysql but depending on how you’ve installed MySQL it might be elsewhere.

As you’ll probably see that’s not a location you can just regularly view in the Finder on Mac so you’ll need to use the ‘Go to Folder…’ option within the ‘Go’ menu in the Finder.

Once you’ve got to that location you’ll see the MySQL data folder which shows up with a red no-access symbol on it so you can’t actually navigate straight into it via the finder. Seeing as we can’t access the folder to restore a specific database we’ll just restore the whole folder from the Time Machine backup instead.

Image of MySQL's Data folder in the Finder

Step 2: Shutdown your MySQL server

It’s important that you shut down your MySQL server process before you continue. How you do this depends on how you’ve got MySQL installed. If you installed MySQL from the official installer for OS X downloaded from the MySQL website then you may have the a System Preference which you can use to stop it.

If you’ve installed MySQL another way such as self-compiled or via Mac Ports or you just want to use the Terminal then you can stop it from the Terminal instead. The following command can be used:

sudo mysqladmin shutdown

If you don’t have MySQL configured in your path in Terminal you may need to use the full path to the mysqladmin command:

sudo /usr/local/mysql/bin/mysqladmin shutdown

The path to those files may vary depending on how you’ve installed MySQL so if it doesn’t work then you’ll need to check the correct location. Note that I’ve also used ‘sudo’ in that command in case you need root privileges to stop the MySQL process. Check the MySQL documentation for your version of MySQL for further help.

Step 3: Rename your MySQL data folder via the Terminal

Image of file listing in OS X's Terminal applicationThe next step is to rename your MySQL data folder temporarily to avoid any clashes when restoring the data folder from the Time Machine backup. First you need to get into your MySQL directory:

cd /usr/local/mysql

You can then list all the files to check you’re in the right place:

ls -al

You should now see all the files including the ‘data’ directory where the databases are located. We can now use the following command to rename the data directory:

sudo mv data data-bak

Once that’s done you should see your directory happily renamed in both the Terminal and the Finder window.

Step 4: Enter Time Machine to restore your MySQL data directory

The next step is to enter Time Machine mode and restore the data directory from the backup. I’m sure you probably know how to enter Time Machine mode but make sure you enter whilst focused on the MySQL Finder window.

Image of restored files in Finder windowGo back in time a sufficient amount so that you’ll definitely be getting the version of the data that you want, highlight the data folder and click Restore. Because we renamed the data directory Time Machine will simply restore the data directory without any prompts. You should now see both the restored data directory and the renamed data-bak directory.

Step 5: Copy the database from the restored data directory

You can now copy the database from the restored data directory, this is done via the following Terminal command:

sudo cp -R data-bak/my_database_name data/my_database_name

The database is actually a directory containing other files so you need to use the ‘-R’ flag to recursively copy all of these across with the directory itself.

Step 6: Delete the restored data directory and rename the data-bak directory

Now that the database is restored and copied you can safely delete the restored data directory as it’s no longer needed at this point. Note: Be very careful using the ‘rm’ command! Bad things can happen if used incorrectly!

sudo rm -R data

You can then rename the data-bak directory back to it’s original name ‘data’, note that the ‘mv’ command doesn’t require the ‘-R’ flag:

sudo mv data-bak data

Step 7: Check file permissions / ownership

You may need to check the file permissions and ownership of the database that you have just restored to make sure that it will be accessible by MySQL when it is running. These may vary depending on your MySQL install method but they should be something like this:

drwx—— 60 _mysql wheel 2040 8 May 12:14 my_database_name

Basically the directory is owned by the user ‘_mysql’ and in the group ‘wheel’. If you need to change the owner then use the following command:

sudo chown -R _mysql data/my_database_name

Step 8: Start up MySQL

Once this has all been done, you can then start MySQL again using either the System Preference if you have it or via the Terminal command:

sudo mysqld_safe &

or with the full path:

sudo /usr/local/mysql/bin/mysqld_safe &

Step 9: There is no Step 9!

Hopefully you should now be able to access your newly restored database. As I said at the beginning, this is the method I used to restore a database myself recently, there may be other ways to do it but hopefully these steps might be of use to anyone else in the same situation.

How to make your Nokia N95 more like an iPhone

My recent switch to an iPhone after using a Nokia N95 for the last year and a half has been great, there’s a load of features on the iPhone that just make a load of sense.

I’d always been keen to try out the various apps available from the Nokia Labs website on my N95 so I thought I’d just do a quick post with links to apps that can make your N95 just a little bit more like an iPhone! These will also work on many other S60 Symbian OS Nokia phones and they are also free downloads from the Nokia Labs website!


SMS management on the iPhone is great as it gives you a view that’s similar to that found in an instant messaging app like iChat / MSN etc. It’s great as it allows you to see the messages in the form of a conversation. The Conversation app from Nokia allows to you something pretty similar.

Contacts on Ovi

This app mainly provides an Instant Messenger experience but also adds some cool features like status updates and location updates. If you’ve been envious of the Brightkite app for iPhone then this is something similar.

Friend View

If you need a bit of a Twitter fix (ok, I know that you can get actual Twitter apps for Symbian!) or want more of a Brightkite experience then Friend View offers location and micro-blogging service.

Nokia Audiobooks

The iPhone is, obviously, a great music player that will also play audiobooks with various controls. The N95 in comparison is an ok music player but isn’t up to playing audiobooks. However, Nokia Audiobooks fills that gap by allowing playback of highly efficient audiobooks by using tools like bookmarking and browsing chapters.

Set your camera to low quality and don’t record video

Ok, this last one is a joke. It’s true that in comparison to the N95 the iPhone camera is not great, it’s poor in low light and doesn’t support video recording at all. So if you want an authentic iPhone experience on your N95 change your picture settings on the N95 to their lowest and you’ll get something similar to the iPhone! (although probably still better!).

Macworld 2009 Keynote – Highlights

So, Macworld SF 2009 Keynote, where was the iPhone Shuffle!?!!? Devastated.

Oh well, I thought I’d point out some of the highlights of the announcements, at least the things I picked up from following various live bloggings of the event! So I guess it’s kind of a live-blog of live-blogging! I’ll possibly write some more at a later date if there’s anything that really grabs my interest.

iPhoto ’09

Facial recognition tagging support and syncing with Facebook and Flickr. Any photos that get tagged on Facebook will sync back the tags into iPhoto, I think my wife is going to like that feature as she is a major Facebook image uploader.

iMovie ’09

I was one of those people who liked the iMovie ’08 already, but this new version of iMovie seems to provide all the missing features that people were looking for. The new version was demoed by Randy Ubillos who was the guy who re-engineered iMovie in the first place, I hadn’t realised that he was actually the original creator of Adobe Premiere. So I guess this proves he knows his stuff.

Garageband ’09

The ‘Learn to play’ feature looks pretty cool. There are lessons for both keyboard and guitar from popular artists like Sting, Nora Jones and Fall Out Boy. As my daughter just got a guitar for Christmas I think that will be pretty useful. There are 9 free lessons included and you can buy more via a built-in store in Garageband.

iLife ’09 – Available now on the Apple store →

iWork ’09

Some nice new features, Keynote can be controlled via the iPhone / iPod touch using a new app that you can buy from the App Store. Pages has a full screen view, a bit like the edit mode in iPhoto, which makes full use of all screen area (I remember Mac OS 6 had this ‘feature’ built in, you could only run one app at a time!). There’s now linking between Pages and Numbers so data driven features in Pages can use Numbers as a source.

iWork ’09 – Available now on the Apple store →

Ok, so this is connected to the iWork suite but it’s a cool enough and notable feature I thought it was worth highlighting by itself, if for no other reason than to point out how dumb the iMovie in the cloud rumours were! iWork is initially a free beta but will eventually be a paid service (I think Apple learned a lot from the MobileMe launch!), basically you can share iWork documents online and people can view them in the browser and comment on them or download the file to edit and make changes. Very similar to Google docs.

Mac Box Set

As all the iWork and iLife apps only run on Leopard Apple have released the Mac Box Set which brings iWork, iLife and Mac OS X 10.5 in one pack for £149, that’s a pretty good deal. It’s interesting that there’s no mention of Snow Leopard here at all!

Mac Box Set – Available now on the Apple store →

17" MacBook Pro

The rumours were right of course, a non-removable battery! Now before you go complaining it’s for a very good reason. It supposedly provides 8 hours of charge and can be charged 1000 times (compared to 200 – 300 charge cycles on a regular battery).

Other key specs are up to 8GB if RAM, 320GB HD by default with 256GB SSD drive as an option, also an optional non-glare screen! 2.93Ghz processor, 60% greater colour range on the screen. I’m sure it’s going to generate a lot of discussion due to the fixed battery but as it’s less than an inch thick it’s pretty impressive, especially if it can run for 8 hours driving all of that screen resolution! Available at the end of January for US $2799 or UK £1,949).

17" MBP – Available now on the Apple store →


All iTunes music will be DRM free by the end of this quarter! There is also new pricing ranging from $0.69 to $1.29. iTunes Music Store on iPhone / iPod touch can now be accessed via 3G network too. All songs will be in the 256k format too.

Some interesting statistics they told were: 6 Billion songs sold, 10 Milion songs available, 75 Million iTunes accounts. I think the flexible pricing was what it took to get the DRM free music, it was definitely needed seeing as Amazon MP3 store has had a lot more DRM free music than iTunes for quite some time.

Yikes, Macworld Keynote live blog haxx0r3d Keynote Liveblog getting haxx0r3d

I had 3 web pages open with liveblogging of the event when suddenly random messages, rude words etc kept creeping in and then it went completely pear-shaped!

No Mac Mini, no iPhone Nano and no Snow Leopard demo!

Two updates that didn’t appear though were a new Mac Mini and the fabled iPhone Nano. Now the iPhone nano I was dubious about anyway but the Mac Mini I was sure was going to get an update, perhaps they’ll do a soft-announcement soon? Also missing was a demo of the OS X 10.6 ‘Snow Leopard’, a lot of people expected to see a demo or at least get some hint of features or progress. I think the Mac Box Set kind of indicated that there wouldn’t be anything being released in the near future.

Well, that’s my live-blog of live-blogging over, time to go check out the Apple website to read more about it all!

Is this the new Mock Mini, erm, I mean Mac Mini…

Macworld San Francisco will soon be taking place and as ever the rumour-mill is hot with talk of a revamped Mac Mini, along with the talk there are the usual sketchy photos of the supposed new products!

MacObserver linked to a post on which shows one of these sketchy product shots, however, I took one look at it and thought "That’s been Photoshopped together"! It got me thinking that I should make my own mockup of a Mac Mini just to show how easy it is, and also how obvious the Macenstein shot looks to me.

Presenting the new Mock Mac Mini!

The world's fakest desktop computer

This is my version of the Mac Mini that Macenstein have published, the main thing I think looks odd is the thin gap at the top of the casing, it pretty clearly looks like the closed lid of the current MacBook / MacBook Pro. And that’s exactly what was used to make this mockup, just two images, the first taken from the current MacBook webpage and the second from a picture of the current Mac Mini:

Using Photoshop CS4 I simply duplicated the first image of the MacBook, flipped it horizontally, cloned out unwanted elements and then used Content Aware Scaling to resize the case and the background. I then copied and pasted the drive bay slot from the Mac Mini picture and blended that in.

Voila, one dubious unreleased Mac Mini!

Goodbye N95, Hello iPhone

It’s been 18 months since I got my Nokia N95 and I’ve enjoyed using it, the combination of a phone with a good quality still camera and also pretty good video camera along with wifi access has been great to use.

Since getting an iPod touch last christmas it was pretty much inevitable that once my phone contract was up that I would switch to an iPhone. Although the N95’s killer app is a great camera, the array of applications for the Nokia N95 pales in comparison to what is available for the iPhone and iPod touch.

In contrast to the N95 the iPhone’s biggest weakness is its camera, much lower resolution stills and no video support at all. However, overall the iPhone is a much better device so I will live with the camera as it is and will probably keep a pay as you go sim in my N95 and still make use of it for filming and photos. The iPhone’s killer app is the fact that there are many killer apps available for it due to the success of Apple’s App Store.

When I got the N95 back in June 2007 I called it my iPhone substitute, it’s served me well but I’m enjoying using my iPhone a lot. It’s sure to be the subject of a few blog posts in the months to come.


Top ten useful Quick Look plugins for Mac OSX 10.5

One of the best new features that OSX 10.5 Leopard introduced was Quick Look. As the name suggests it lets you take a ‘quick look’ at the contents of a file without having to open up the actual software application.

Quick Look supports plugins so third-party developers can create Quick Look plugins of their own to give access to many other file formats. I’ve found Quick Look to be such an intuitive tool to use as well as incredibly time saving due to not having to wait for Microsoft Word open up just to check the contents of a Word document. A great boost for productivity!

Here, in no particular order, are 10 of the most useful Quick Look plugins that I’ve found. Please note, some of these require payment for full use:


Allows you to preview ZIP, TAR, GZip, BZip2, ARJ, LZH, ISO, CHM, CAB, CPIO, RAR, 7-Zip, DEB, RPM, StuffIt’s SIT, DiskDoubler, BinHex, and MacBinary files.

HD Quick Look

HD Quick Look lets you view the first frame of your AVCHD files. You can also view multiple files as a slide show, as an index sheet or full screen.

This is a really handy plugin for those working with AVCHD video and a perfect companion to Shedworx excellent VoltaicHD application for converting AVCHD footage!

Suspicious Package

It allows you to preview the contents of a standard Apple installer package without launching the Installer. Great for checking for any unwanted additional bits of software that sometimes companies like to add!


Gives a preview of AppleScript files.


Allows you to view Flash video files, please note that it requires installation of the Perian Quicktime plugin to make it work.


Allows you to view EPS files.

Folder View

Allows you to see the contents of a folder.


Enables display of XML files with indentation and XML syntax coloring.

SneakPeek Pro

Allows you to preview Illustrator, InDesign and EPS documents in the Finder, dialog boxes and other applications. SneakPeek Pro also allows you to see fonts, images and colors used in many CS3 documents.

It works with Illustrator files even if not saved with PDF compatibility. $19.95 but worth every cent if you’re a frequent Illustrator or InDesign user!


Adds enhanced source code colouring for various programming languages such as PHP, Actionscript, Objective-C etc.

Review: Apple Composite AV cable for iPod Touch, iPhone, Nano etc

Picture of Apple's Composite AV cable for iPod Touch / iPhoneI just bought myself the Apple composite AV cable for my iPod Touch so that I could hook it up to my TV to watch BBC iPlayer programmes. At first I thought the £35 price tag was pretty steep, but seeing as I was at the Apple Store in Glasgow I thought I’d treat myself to something!

On closer inspection though I saw that it isn’t just an AV cable but it also has a USB cable which plugs into a dinky little power supply which comes with both UK and North American power supply connectors, so basically it can be used to charge your iPod and also means that you don’t run out of power whilst watching programmes on it.

Basically the AV cable enables you to watch or listen to any video, audio or images that are on your iPod directly on your TV, this also includes the YouTube application too. Image slideshows can also be viewed via the AV cable.

Those standard features are pretty awesome in themselves but the killer app combo for me is this:

  1. The BBC offer a version of their iPlayer specifically for the iPod Touch and iPhone
  2. The AV cable for the iPod Touch / iPhone can play the iPlayer content on your TV

Screenshot of BBC iPlayer for iPod Touch / iPhoneIt’s a pretty simple combo but it’s awesome being able to play all the iPlayer content on your TV instead of on your computer. The great thing too is that the iPlayer content via the iPod is actually better quality than the streaming Flash version that you would view on your computer due to it being delivered as H.264 encoded video rather than the Flash ON2 codec that the regular iPlayer uses.

Well, I can’t recommend it enough, the price tag might seem a bit high at first but it’s a high quality cable that provides a power supply and AV connections as well as the ability to use it as a regular USB iPod cable too. If you happen to live in the Uk and have access to the BBC iPlayer then it makes that accessible right in your living room.

The AV Cable is also available for Component video connections too, you can pick one up from the Apple Store online:

Composite AV Cable

Component AV Cable


Adobe Open Screen: Will Apple make their own Flash Player for the iPhone?

Adobe recently announced the ‘Open Screen‘ initiative which further opens up the SWF format along with the FLV / F4V video specifications along with . The Open Screen FAQ explains the core deal:

  • Removing restrictions on use of the SWF and FLV/F4V specifications
  • Publishing the device porting layer APIs for Adobe Flash Player
  • Publishing the Adobe Flash® Cast? protocol and the AMF protocol for robust data services
  • Removing licensing fees ? making next major releases of Adobe Flash Player and Adobe AIR for devices free

The FAQ also explains why Adobe is opening up these specifications:

Publication of an unrestricted SWF file format has long been requested by the Adobe Flash developer community. The longstanding publication of the SWF specification has fostered a vibrant ecosystem of companies and developers who create experiences with Adobe Flash technology and by removing the SWF licensing restrictions we are allowing that growing ecosystem to use the file format for any purpose, including the ability to playback SWF content

Additionally, Adobe intends to make Adobe Flash Player and Adobe AIR for devices free, starting with the next major releases for devices, along with publishing the device porting layer APIs. As a result of these moves, OEMs, software developers, and content owners will be able to deliver content and applications built with Adobe Flash and Adobe AIR technologies without concerns about device restrictions. By removing the licensing cost and restrictions, as well as opening up the protocols and porting layer, Adobe is making it easier for developers and partners to deliver more engaging experiences to more of their customers, and ensuring that audiences can engage with content no matter what device or medium they use.

So, with that background detail out of the way I’ll get onto my main question:

Will Apple get involved in the Open Screen project and provide support for Flash, or at least Flash video, on the iPhone / iPod Touch?

Steve Jobs was recently asked about Flash support on the iPhone by saying ?there?s this missing product in the middle?. What he was referring to is that you’ve got the full Flash Player which is very processor intensive and best suited for desktop PCs and laptops and then you’ve got the streamlined Flash Lite intended for mobile devices. Steve Jobs’ opinion is that the full version is too intense for the iPhone whilst Flash Lite lacks a lot of important functionality.

Could Apple provide at least some form of Flash support on the iPhone / iPod Touch by getting involved in Adobe’s Open Screen initiative and implementing only the parts they wish to have for Flash playback but all within the confines of the Quicktime framework itself I can see how this could fit in on regular Mac OSX as well as on the iPhone / iPod Touch too. I think it presents a really interesting possibility.

I have another reservation about Apple’s willingness to support Flash though, perhaps it’s not in Apple’s interest to further the spread of Adobe’s Flash platform? Apple certainly don’t intend to allow companies to develop runtime environments of their own for use on the iPhone / iPod Touch as the terms of the iPhone SDK specifically state:

"No interpreted code may be downloaded and used in an Application except for code that is interpreted and run by Apple?s Published APIs and builtin interpreter(s)…"

So, that certainly seems to close the door for Java, Flash, Silverlight, etc, etc. Despite this possible reason I still think it is possible that Apple could provide native support for Flash video playback, at the very least, on the iPhone / iPod Touch.


Intel chips do not a virus-magnet make!

Browsing around the BBC website the other day (enjoying their new updated customisable homepage!) when I came across a Blog post titled: "Mac virus alarm is sounded – again". The author, Derren Waters, begins warily:

I hesitate to write this, mainly because I fear the response, but does anyone who owns a Mac actually use any anti-virus software?

It’s an interesting question and one which a friend asked me at work recently as he had just purchased his first Mac – a nice shiny MacBook. Derren’s blog post received a lot of comments ranging from "Macs are not real technology", "Mac users are so smug", "I use anti-virus just to be safe" and the perennial favourite "Macs don’t get viruses because they have a much smaller market share so virus writers don’t see them as much of a target"!

I don’t think these comments are surprising, no harm in running antivirus software if you want to (although much antivirus software on both Windows and Mac is renowned for causing performance issues, cough, mcafee…).

Amongst the many comments one stood out to me in particular as it suggested that as Macs now use Intel chips they are somehow more vulnerable than when they were running on PPC chips:

Yes, I use Macs and I do use antivirus software. It is only a matter of time before we users get hit with viruses; even more so now with the Intel processors being used in more and more Macs

There’s not really any logic to this suggestion, it’s the operating system and not the chip that presents the vulnerabilities, Windows wouldn’t be any more or less secure whether it was on PPC or Intel. I do appreciate there are perhaps specific functions in processors that could in theory be a gateway for malware of viruses but it would still have to get past a piece of software in the form of an operating system or at least firmware.

Personally I don’t run antivirus on my Macs as I don’t see it as necessary. Running a Firewall is a good idea and going online via a router with a firewall is also a great way to remove your computer from port scanning script kiddies too. Obviously it’s important not to be naive (or smug!) but OSX’s UNIX heritage provides a very secure base to the operating system, the biggest risk a Mac user faces is themselves as the closest thing out there to any kind of malware or trojan for OSX involves the user being duped into running something because they didn’t expect.

If you’re a Mac user and you’re concerned about security then I’d suggest the following simple steps:

  • Disable the ‘Open "safe" files after downloading’ preference in Safari – this stops images, movies, sounds, text from opening and disk images from mounting automatically after downloading. This alone is a simple way to stay in control of files being opened.
  • Make sure your firewall is enabled
  • Enable software update to automatically download updates, and make it check at least weekly if not daily for any available updates. Apple release software updates fairly frequently including a fairly regular Security update.

I tried to post a comment on the aforementioned blog post but the blog tool behind seems to be faulty, so I thought I’d just write a post instead :) As I write, this comic on comes to mind:


MWSF 2008: Why is Apple charging for iPod Touch application updates?

Well Macworld San Francisco was upon us again, as usual Apple didn’t disappoint in delivering some cool things.

MacBook Air, iTunes video rentals, Apple TV V2, Time Capsule WIFI backup drive to name a few. There was also an update for applications for the iPhone and new applications for the iPod Touch. The update for the iPod Touch brings Mail, Weather, Maps, Notes and Stocks apps to iPod Touch users, however there was a slight sting in the tail for existing iPod Touch users as the update will cost you £12.99 / $20!!! Ouch.

As annoying as this is (especially as these can be had for free if you jailbreak your iPod Touch!) I’m wondering if this is not just a matter of accounting requirements on Apple’s part?

A while back Apple introduced new MacBook Pros which had support for the new 802.11n WiFi networking but which wasn’t enabled to begin with. Apple then brought out new Airport Extreme base stations which supported 802.11n, anyone who had one of the new MacBook Pros had to pay a small fee for a bit of software to enable this functionality. I wonder if the upgrade charge for the iPod Touch applications is down to the same GAAP accounting policy that was at the heart of the 802.11N WiFi enabler? It seems odd to charge existing users for this but give it free to new purchasers otherwise.

As far as the iPhone app updates are concerned they are free as the iPhone purchases are accounted in a subscription method so these kind of updates can be provided free of charge. So, good news for iPhone users but slightly annoying for people like me who have an iPod Touch!