April 4th 2012

Installing A Standalone Instance of MySQL on Mac OS X

Recently I decided I needed to broaden my horizons and learn a bit more about Ruby on Rails, whilst using a MySQL database back-end. I’m a fan of XAMPP and have been using it for years. Of course MySQL comes with XAMPP however, I was reluctant to mess around with this installation when it came to setting up Ruby on Rails. Instead, I opted to install a standalone version of MySQL for use with Ruby on Rails. I encountered a few difficulties along the way so thought I’d write this blog. It’s not exactly a step-by-step guide but hopefully something in here will help others.

1. Install XCode
XCode is Apple’s suite of developer tools. It’s a free download from the Mac App Store. Download it from there and it should install itself, no problem.

2. Install Homebrew
Next, you need to install Homebrew. Homebrew is an open source package manager for OS X. This is what we’re going to use to help install MySQL. Before we installing Homebrew, we need to make a folder for the packages we will download. This will be done via the Terminal (if you’re unsure where to find this, it’s under Applications > Utilities > Terminal).

mkdir -p /usr/local/Cellar

Now we are ready to install Homebrew using the following command in the Terminal

/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

If you’re having trouble installing Homebrew, more information can be found at https://github.com/mxcl/homebrew/wiki/installation

This may take a short while (I’ve forgotten how long it took me). If you want to check it has installed correctly, run the “brew doctor” command. This will alert you to any issues, such as problems with the PATH variables. I’m not going to cover errors with Homebrew in this particular blog however, if you do encounter troubles, there are a number of sites out there providing useful help.

3. Installing MySQL
Once Homebrew has installed and any errors have been resolved, run the following command to install MySQL:

brew install mysql

Again, I can’t remember how long this took to install but it didn’t take an overly long amount of time, if that’s some comfort. It would be a great time to go and get a cup of tea though.

After this, we need to set the MySQL server to launch at start-up, though I’m not convinced this worked as it should on my machine. Just remember to change the version number in the command below, in accordance with the one you are using.

mysql_install_db --verbose --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.5.20/com.mysql.mysqld.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

4. Running 2 instances of MySQL simultaneously
Here’s where the fun and games begin. We already have MySQL installed on the Mac- the version which came with XAMPP. MySQL usually runs on port 3306 and obviously, this will cause chaos if we try and run 2 versions at once (slight exaggeration there: it won’t cause chaos but it just won’t work!).

In order to prevent any conflicts, I decided to force the standalone version of MySQL to run on another free port. In my case, I chose port 3307. If you’re unsure which port to use, there’s a port scanner included with OS X under Applications > Utilities > Network Utility and this will help you identify a free one. Still, 3307 should be ok.

Navigate to usr/local/etc/my.cnf. If there is no my.cnf file, make one. Copy and paste the following information into it (this information sets MySQL to run on port 3307 on localhost):

[client]
port = 3307
socket = /tmp/mysql.sock 
 
[mysqld]
event_scheduler = ON
skip-character-set-client-handshake
collation_server = utf8_unicode_ci
character_set_server = utf8 
 
bind-address = 127.0.0.1
port = 3307
socket = /tmp/mysql.sock
max_connections = 20

Before we go any further, I would suggest starting up XAMPP and navigating to http://localhost/phpmyadmin in your browser, just to check that it’s still running correctly. There’s no reason the standalone version should interfere with the XAMPP version but you might want to double-check for peace of mind (I did).

5. Here come the errors (probably)….
At this stage, you’re likely to get errors with the MySQL installation. Want to test it and see if that’s the case? Enter the following into the Terminal:

mysql.server start
mysql

Chances are, this will generate the “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)” error. That’s because we still have a few things to change to resolve any issues.

Navigate to /usr/local/Cellar/mysql/5.5.20/support-files/mysql.server

Near the start of the file you should see the following lines:

basedir=
datadir=

Change these lines to:

basedir=/usr/local/Cellar/mysql/5.5.20/
datadir=/usr/local/Cellar/mysql/5.5.20/data

It may seem obvious but check your version number and add in the appropriate one- I’m running 5.5.20 but off the top of my head, I’m not sure if that’s the latest version.

Try starting the server again by using:

mysql.server start
mysql

You may still get an error which says something along the lines of “ERROR! Manager of pid-file quit without updating file.” I’m not entirely sure what that’s all about but it’s not good.

Again, you need to navigate back to /usr/local/Cellar/mysql/5.5.20/support-files/mysql.server

Locate the following line:

mysqld_pid_file_path=$datadir/`/hostname`.pid

Change it to:

mysqld_pid_file_path=$datadir/`/bin/hostname`.pid

Now try:

mysql.server start
mysql

Hey presto, it should work! Go and have a celebratory cup of tea. If the installation still gives an error, get a cup of tea anyway- you’ll probably be needing one by this stage. Most likely, there will be an issue with file permissions some where along the line. I found this thread on stackoverflow to be quite useful. Basically, you may need to “chown” a few folders.

6. Installing the MySQL Preference Pane
There’s nothing to see here, move along. What I’m trying to say is, I battled with the prefpane. I wanted it to work, I really did but it didn’t. In short, it was a pain in the backside. It only wanted to start/stop the MySQL installation in the default location which is /usr/local/mysql as opposed to /usr/local/Cellar/mysql. Just use commands in the Terminal instead to start/stop the server:

mysql.server start
mysql.server stop

7. Useful Information
Whilst trying to install MySQL, I found both Frederico Araujo’s blog and Jason Seifer’s blog to be useful resources.

Additionally, you may find the MySQL Workbench tool handy when managing various databases. It serves as a neat front-end and allows you to either type SQL or interact with a user interface.
*     *     *     *
As I previously mentioned at the beginning of this post, this isn’t a fine-detailed guide to installing a standalone version of MySQL whilst running XAMPP- there are a number of errors which could appear and I couldn’t possibly anticipate them all. However, if there are people out there who have been struggling, I’m hoping this post at least provides some guidance.

Now I just need to get started on building something with Ruby on Rails….

March 9th 2012

Durolane Round 1 Update

Apologies- I meant to update my blog regularly with news of how my hip was holding up following the Durolane injection I had in June 2011. My 3 month check-up was in September and that went very well.

How are things now? Well, there’s good and bad news.

The good news: my hip felt great over the winter. The cold weather usually irritates it but due to the combination of the mild winter and the Durolane, I barely felt it. In fact, I’ve hardly taken any painkillers at all (though I am still remaining teetotal as I have done since 2008 ;) ). My hip did have the occasional day where it hurt but those were days where I’d overdone it. Overall, my hip has been fantastic and it’s been nice to go out for walks without the need to take painkillers first.

The bad news: all good things must come to and end. This is now the beginning of March, 8 months on from the injection and the Durolane is wearing off. I’ve already been to speak to my Dr and have been referred for another injection. Whilst I’m dreading the thought of being back in the operating theatre, getting stabbed with a javelin, I know it’s worth it. Anything to stave off the inevitable hip replacement.

February 26th 2012

My Thoughts On The Windows 8 Dev Preview

Perhaps I’m a little behind the times since I’ve only just installed the Windows 8 Developer Preview (when it was actually released mid-December). Nevertheless, I’ve been playing around with it to get a feel for it.  Before I go any further, it should noted that the preview was running on a MacBook via VirtualBox. I chose not to create an account via my Windows Live ID and instead chose the option of creating a Local Account.

The installation process was easy. A few steps and that was it. Microsoft seem to have improved upon this- as I recall, installing XP took several steps and information had to be entered periodically though the process. Maybe I just think it’s easier because I’m more experienced now?

Right, initial thoughts on the interface. First off, it’s very green but not in a bad way. The Start Screen is colourful, and filled with a selection of apps and options- I believe this is the Metro interface (I have included an image of it). As soon as I saw it, I wanted to start using my laptop screen as a touchscreen. Since it isn’t a touchscreen, it would do nothing other than generate a mass of greasy fingerprints.

Windows 8 Start Screen

This leads me to my first piece of criticism of the developer preview- the interface seems geared towards tablet devices and I’m not sure that translates to the desktop experience. One of the apps I played around with was the Piano one. It was ok using the mouse but it’s something I would have preferred to use on a touchscreen- it would have been much faster. Microsoft seems eager to demonstrate the capabilities of the Metro interface which is fair enough because it is nice but again, I’m not sure these touchscreen apps adapt to suit a desktop environment.

Another app I looked at was the Internet Explorer app. I only experimented with it briefly but the thing I found odd was that the address bar was at the bottom of the screen! It was surrounded by black so it was unobtrusive but it struck me as an odd place to put it. Thinking about it, it’s actually a good place to put it- it doesn’t get in the way of the top part of the website you’re trying to view. It’s a neat app. For those that are panicking, the standard desktop version of Internet Explorer is also included so you’re not forced to use the tablet-optimised one.

One thing I found a little odd was the lack of an X in the corner to close an app. Instead, pressing the Windows key on the keyboard works as an X button. I guess this relates to tablet features being included with the OS, as on those devices, you press a “Home” button or something similar to leave an app.

For seasoned users who are worried this is a totally different version of Windows they’ll have to get used to, fear not, the traditional desktop environment still exists and Windows Explorer is there to use.

Shutting Down

When I was finished playing around with the preview, I needed to shut down the machine- this is where I ran into a problem. How do you normally shut down a Windows computer? Start > shut down. When I tried this in Windows 8, there was no shut down option. I resorted to Google which told me I had to click on the Start button, then click on settings. This produced a large green sidebar on the right of the screen. You then have to select power from this menu, then you can finally shut down. I’ve been a Windows user since around 1997/1998 and I felt a bit silly because I didn’t know how to shut down- why has this changed and what was wrong with the old way?

My overall thoughts. I think the Windows 8 Developer Preview looks quite nice but many of the UI features are geared towards tablet devices, and it doesn’t quite work in a desktop environment. That said, at least they have included the desktop Windows users have come to expect so there isn’t a huge learning curve for existing users. Personally, I think Microsoft should stick to having a separate desktop and tablet/mobile OS, like Apple have OSX and iOS. That’s just my 2 cents. Of course, the Consumer preview is supposed to be released on the 29th of February so things may have changed!

December 31st 2011

2012 Resolutions

2011 has been a rough year and I’m glad to see the back of it. Many things haven’t gone as planned this year and at the end of the summer I lost a beloved family member, a loss which I feel every single day.

2011 has had a few good moments. The 8 days I had in New York City with my best friend were amazing. We crammed in so much: Top of the Rock, New York Public Library, Bryant Park (and chess!), Times Square, Liberty Island, Ellis Island, Battery Park, Wall St, New York Yankees vs Texas Rangers, Hershey’s, Museum of Modern Art, American Museum of Natural History, The Met, Central Park, the Upper West Side, comic book stores, 5th Avenue, Grand Central Station and lots of Starbucks. Great times.

I digress. Here are my resolutions for 2012:

  • Get fitter. Specifically, I want to build up more strength in my hip. The Durolane is slowly wearing off (but I’m ok just now) and I think a little more muscle would provide a but more support for it. I just have to be careful and stick to my limits.
  • Try and get a full-time position- I love my job at the moment but it’s a temporary contract. If I could get the same job permanently, I’d be ecstatic.
  • Attend more gigs and performances- what can I say? I’m always up for seeing more shows.
  • Spend more time with friends- actually, I’ve already been working on this. I’ve seen my friends more this year than I have in previous years. There’s still some I haven’t seen in a long time though!
  • Improve my photography- do I need to explain this one? I feel I haven’t been out with the camera much this year so I need to rectify that. I’m seriously considering another 365 challenge like the one I did in 2008 (see my 2008 challenge pics ).

So here’s to 2012. Let’s hope it’s a good one (and that the world doesn’t end!).

One last thing, since I’m watching 30 Rock as I write this, I’ll leave you with a Liz Lemon quote- “One of my New Year’s resolutions is to say yes. Yes to love. Yes to life. Yes to staying in more!“.

November 27th 2011

Bryan Adams, AECC Aberdeen, 26th Nov 2011

bryan adams aecc

The AECC was where I saw my first Bryan Adams concert, back in October 2004. I was only 16 at the time and was still in High School. I loved it. I distinctly remember arriving home quite late after the concert, being in awe of Bryan and the band and telling my mum that I “just HAD to see them again”.

Flash forward to the present day. 7 years later I found myself back the AECC eagerly awaiting my 7th Bryan Adams show. There was a tiny queue at the west entrance so when the doors opened at 6.30pm, I had time to buy a t-shirt, get some water and get a good spot in the 2nd row, in front of one of Bryan’s mics.

This year marks the 20th anniversary of the Waking Up The Neighbours (WUTN) album. To mark the occasion, he decided to do a tour in the UK. I’d been looking forward to the gig since it was announced at the end of March. Back in 1992, I was way too young to attend the original tour dates for the album.

Highlights of the show….

House Arrest- What an opener- It got everybody going. It also happens to be a favourite of mine from WUTN and it was the first time I’d heard it live.

Here I Am- I’ve only ever heard this played live acoustically (in Dundee and Glasgow). Great with the full band too.

All I Want Is You- Another of the songs from the WUTN album and it rocked. Again, I hadn’t heard this live before.

Thought I’d Died And Gone To Heaven- Also from WUTN. Yet again, this was another tune I hadn’t heard live. Fantastic to hear.

Hearts On Fire- The guitar solo battle between Bryan and Keith Scott. Need I say more?

Do I Have To Say The Words?- I first heard this live in Glasgow last year, but that was on acoustic guitar. Very powerful with the full band.

Summer of ’69- This song is always in the highlights of any gig I go to. It sends the audience wild and you can feel the energy in the room.

Is Your Mama Gonna Miss Ya/ If You Wanna Leave Me / Touch The Hand (medley)- First off, the medley was fantastic. All 3 songs were from WUTN and they are rarely/almost never played live. What made it even better was the way it was arranged. Mickey Curry came to the front and played the drums on buckets, pots and pans. Keith joined in on a plastic bucket (and looked like a kid who was enjoying himself) whilst Norm Fisher played “bass” on another bucket. You couldn’t make this stuff up. Sorry to use the phrase but it was epic. I don’t know how it worked but it just did.

It’s Only Love- Keith Scott and his fingers of fire- wow. How he manages to play the way he does is beyond me. The solo was amazing. I still remember the first time I saw Keith play the solo at a gig- my jaw literally dropped. He’s a legend.

Depend On Me- Another WUTN tune and another first for me.

When You’re Gone- Kerry from Laurencekirk was chosen as the WYG and she did a fantastic job- no nerves at all! I was really pleased someone from Laurencekirk was chosen as that’s where I went to High School.

There Will Never Be Another Tonight- This just happens to be one of my favourite songs. In the past I’ve seen it used as an opener. No matter where it is in the set, it still rocks.

The Way You Make Me Feel- Bryan wrote this song for Ronan Keating but last year, he included it on the Bare Bones album. This was my first opportunity to hear it live myself.

Other thoughts about the show?

I for one was really glad to see Keith Scott back. The acoustic shows were great with Gary Breit and Bryan but I missed Keith. Not only that but I’ve missed his solos- he’s a heck of a guitar player.

Also, the lighting set-up for the show was spectacular. By the looks of things, lasers were used and when they were blasting around the arena towards the end, it was really pretty. The giant screen at the back of the stage showing various graphics (and the Twitter feed) brought the whole show together. It was impressive.

Finally, the setlist (see the bottom of the blog post for the complete list). Wow. It was a storming set. Rocker after rocker. As you can tell from the gig highlights, there was a large number of songs which I hadn’t heard live before. Brilliant.

My final thoughts on the gig? Every time I come back from one of Bryan’s shows, I say “oh, it was amazing!”. This time is no different. It really was amazing. The most rockin’ show I’ve seen for a long time.

I took a few pics (but not many) and you can find them on my Flickr page

Setlist from the show

House Arrest
Somebody
Here I Am
All I Want Is You
Can’t Stop This Thing We Started
I’m Ready
Thought I’d Died And Gone To Heaven
Hearts On Fire
Do I Have To Say The Words
18 til I die
Back To You
Summer Of ’69
Is Your Mama Gonna Miss Ya/ If You Wanna Leave Me / Touch The Hand (Medley)
Everything I Do
Cuts Like A Knife
It’s Only Love
Depend On Me
When You’re Gone
Heaven
The Only Thing That Looks Good On Me Is You
Run To You
There Will Never Be Another Tonight
Cloud No. 9
The Way You Make Me Feel
Straight From The Heart