Monthly Archives: March 2016

Installing a MySQL server on Mac OS X 10.10 Yosemite or 10.11 El Capitan with or without Server

Apple recently phased out MySQL in favor of PostgreSQL.  There are still valid reasons why we might prefer MySQL, such as compatibility with legacy code.

Here are my instructions on how to install MySQL as a permanent service on OS X. These instructions work with or without OS X Server installed. For the most part, installation is straightforward, but read this carefully because there are gotchas where it comes to file permissions.

I’ve tested these instructions several times on OS X 10.11 El Capitan and 10.10 Yosemite. I think these instructions will probably work on 10.8 Mountain Lion and 10.9 Mavericks.

Backup your MySQL databases.

You want to back up your MySQL databases before doing a OS X upgrade. The easiest way is to create a mysqldump file. Databases can also be restored from data files, but this is harder and I don’t recommend it.

$ mysqldump -uroot --all-databases > ~/Desktop/dump_all.sql

Install or upgrade OS X.

According to your plan.

Download Xcode from the App store and install the command line tools.

Xcode is a dependency for Homebrew, which uses Xcode’s gcc compiler to compile everything from source. Once you have Xcode installed, you need to install the command line tools for the gcc compiler to work. From Terminal:

$ xcode-select --install

Check the systemwide PATH variable.

Open a Terminal window:

$ cat /etc/paths

Make sure that /usr/local/bin occurs before /usr/binIf they don’t, then you need to change this order. Edit /etc/paths using vi or your favorite text editor. I love and use TextWrangler. Close your Terminal window and open a new Terminal window for this change to take effect.

Obtain Homebrew. 

Homebrew is a great package manager for OS X that installs everything in /usr/local/bin and does not require sudo.It then symlinks to the expected locations so that the packages can find one another. Because the packages are centralized in the Cellar, they are easily updated and removed.

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Fix any problems that Homebrew detects.

$ brew update
$ brew doctor

Follow brew doctor‘s instructions. brew doctor usually complains about Xcode. If I’m guessing the error correctly, here is the solution that brew doctor will suggest (assuming OS X 10.10 – note the version since this affects what you will type into Terminal):

$ cd /Applications/Xcode.app/Contents/Developer/Toolchains/
$ sudo ln -s XcodeDefault.xctoolchain OSX10.10.xctoolchain
# note the version (10.10) and modify accordingly.

Run brew doctor again. Continue to follow brew doctor‘s instructions until it tells you that “Your system is ready to brew.”

Install MySQL.

$ brew install mysql
# ignore homebrew's instructions to symlink the .plist file!

Homebrew has just installed MySQL to run under the current user, which is not what we want for our server, but we will get to that in a moment. First, we will test the mysqld service to see if it launches. In newer versions of MySQL, the command to launch the service is $ mysql.server start.

$ mysql.server start
$ mysql.server stop 

Modify the .plist file to improve logging.

Using vi or your favorite text editor, modify the .plist file.

$ vi /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
# use vi or your editor of choice 

Add these lines within the <dict> block:

<key>StandardErrorPath</key>
<string>/var/log/homebrew.mxcl.mysql.err</string>
<key>StandardOutPath</key>
<string>/var/log/homebrew.mxcl.mysql.log</string>

Set up the MySQL service to launch at boot time as part of a server.

Homebrew’s instructions, which I asked you to ignore, would have installed a LaunchAgent for your current user account, so that the mysqld service would start whenever you logged in. This would work great for a personal development machine, but it’s not not ideal for a server.

For a server, what we want is for mysqld to start up at boot time by the root account. So, we need to make two changes:

  1. the .plist must link into /Library/LaunchDaemons and have the appropriate permissions to be launched by root.
  2. the mysql database files in /usr/local/var/mysql must all be owned by  _mysql. You might wonder why the owner must be _mysql, since the server starts up as root. This is because whenever mysqld detects that it is being run as root, the process steps down to user _mysql as a security measure. This is typical behavior for services. Apache, for example, steps down to user _www.

Open a Terminal window, and enter:

$ sudo ln -sfv /usr/local/opt/mysql/*.plist /Library/LaunchDaemons
$ sudo chown root:wheel /usr/local/opt/mysql/*.plist
$ sudo chmod 600 /usr/local/opt/mysql/*.plist
$ sudo chown -R _mysql:wheel /usr/local/var/mysql

Important: Now that mysql belongs to root, do not run the $ mysql.server command again! Don’t do it. This will result in an aborted launch with permissions errors. You will need to delete the resulting .pid files in /usr/local/var/mysql before mysqld will be able to run again, even as root. Again, don’t do it.

Verify that the MySQL service starts up at boot time.

We will reboot the server machine. At boot time, launchctl should load our modified .plist and run mysqld. We will then run the mysql command from Terminal to interface with the mysqld service and verify that it’s running.

 $ sudo shutdown -r now

After the machine restarts, re-enter Terminal and type:

</pre>
<pre>$ mysql -uroot 

If the mysql command fails, then we know that either the LaunchDaemon didn’t kick in, or that mysqld failed to start successfully. Again, if this happens it is usually because of a permissions issue. To troubleshoot, check the log files at:

/var/log/homebrew.mxcl.mysql.out
/var/log/homebrew.mxcl.mysql.err
/usr/local/var/mysql/*.err

Restore your MySQL databases.

$ mysql -uroot < mydumpfile.sql
$ mysql_upgrade

A full dump from a recent version of MySQL should successfully restore all databases plus the privilege table, which controls users. If there are problems with the privilege table after restoring, then edit out the privilege table from your mysql dump file, and re-create your users manually using a tool like phpmyadmin.

I hope this post helped someone. Happy monkeying!

Advertisements

Startup Gear for Indoor Rock Climbing

I’ve been fascinated with climbing for a long time. In college, I took a rock climbing class with my best friend. We were too broke to buy gear, so we ended up sitting in the cafeteria and dreaming big.

Fast-forward to having just turned 40. My body has been converting itself into fat. I wasn’t overweight, but I no longer felt fit. My lifelong passion, skiing and snowboarding, didn’t keep me physically active year-round, and in Maryland the season was short. My then-wife and I talked about rebalancing our lives, like we rebalanced our spending every year. We decided to put more time into taking care of ourselves and less time into working overtime. (Hopefully nobody from my workplace will read this).

I took the kids to the local rock climbing gym, Earth Treks in Rockville, Maryland. The kids were instantly hooked and so was I. A few weeks later I convinced my wife to try it, and although she resisted at first, she became hooked. It’s been five years, and we’ve never looked back. In fact, this kind of investment into my physical well-being was one of the best decisions I’ve ever made.

Soon, we started buying our own gear. I scoured product reviews on Amazon, REI, Backcountry, Moosejaw, evo, and OutdoorGearLab. I made some buying choices that turned out to be good, and others that turned out to be a waste of money.

I’ve explained here what worked and what didn’t. This is based on my experience and what I learned from climbing friends and the community. I didn’t do a systematic analysis like OutdoorGearLab. I don’t have the hundreds of reviews that Amazon has. But I can tell you what this gear is like for me in real life.

1. Climbing Harness

Harnesses cost about $50. If you are set on saving $50, I actually know people who know how to tie harnesses using nothing but tubular webbing. But that’s time consuming, those harnesses are really uncomfortable and it’s impossible to go to the bathroom without untying the whole thing, and then retying it. Let’s not go there.

Since I wrote this original blog, harnesses have evolved to the point where they are basically all the same. I started out with an entry-level all-purpose harness, and when that got old, I bought a high end harness, and barely noticed any difference between the new harness and my old one.

Buy any padded, all-purpose harness that you like, and don’t sweat your decision. If you care, check OutdoorGearLab.

IMG_1892

The kids getting their first harnesses. Making them smile like this is priceless. 10/6/12

No matter what, you will need to replace your harness every 4-5 years, since the nylon eventually breaks down. Nylon breaks down faster if you let it get dirty, or if you leave it outside in the sun. And, don’t store your harness or your other rock gear near gasoline or paint thinner since the vapors will dissolve nylon.

2. Locking Carabiner

You’ll need a pear-shaped locking carabiner for belaying. Biners last forever, so don’t be cheap.

I learned not to bother comparing strength measurements, because all carabiners and most other gear for rock climbing are designed to withstand at least 3,000 pounds of force or 15,000 newtons. At this amount of force the human body breaks into pieces. There’s no point to making gear stronger than what the body can tolerate.

I’ve owned a few different locking biners. By far, my favorite is the Black Diamond Magnetron VaporLock because it’s super easy to use, and super light. It automatically locks when the gate closes. And now it comes in cool black.

3. ATC Belay Device

For an indoor gym with burly gym ropes, I really like the original, old-fashioned Black Diamond ATC. The other variants of the ATC, like the ATC-XP and ATC-Guide, are narrower and for me it has gotten tiring pulling a burly gym rope through them.

Common sense says that a Petzl GriGri 2 should be a safer belay device than an ATC because it auto-cams. This is helpful if you don’t trust your belayer, or if you take huge leader falls, or if your friend hangdogs for hours on end. I own one, but again, with a burly gym rope, the GriGri is so tight that I can’t even lower my kids down from the top of the climbing wall. These days, I only use my GriGri for trad climbing.

4. Climbing Shoes

For climbing shoes, I really recommend going for comfort – meaning an unlined leather “trad” shoe with a flat sole. I’ve messed around with shoes, and the pain really isn’t worth it. You don’t want to start climbing with aggressive shoes. They can hurt so much that they turn people off from the sport. I’ve watched my ex-wife and daughter complain that their feet hurt. Every complaint caused me to experience pangs of sympathetic pain. You won’t need aggressive shoes.. until you start entering bouldering competitions. I used to think that shoes were very important, but my son is sending 5.12 in comfortable Mythos, and enjoying every moment of it.

La Sportiva Mythos are pretty standard, or FiveTen Moccasyns. Because these are unlined leather, they stretch to fit your feet like gloves.

A bit of an overview: shoes come in three materials: old-fashioned unlined leather, synthetic, and lined leather. Old-fashioned unlined leather shoes are the most comfortable, break in well, and breathe well. But, they stretch terribly, so they are difficult to size correctly at the store. Synthetic shoes don’t stretch at all so they are easy to fit at the store, but quickly develop an ungodly stench. Lined leather shoes stretch just enough to offer a customized fit and are a bit easier to size.

Shoes also come in two shapes, called ‘trad’ and ‘aggressive’. Trad shoes, named for trad climbing, are flat-footed and more comfortable. Outdoor climbers need to keep their shoes on for long periods of time. Aggressive shoes have a pointy toe, downturned sole and narrow fit. They are usually uncomfortable if not painful, and are used for competitive climbing or bouldering.

The hardest thing about Mythos is sizing them. They will eventually stretch up to a full size. They also come in European sizes, and the conversion between European sizes and US sizes is inexact.

First, find your size on the ruler below from La Sportiva, which is more exact than using a table. Are you tight or loose in your typical US size? I am a little tight in a US size 10, and a little loose in a US size 10.5. Using this ruler I can see that my exact European size is close to 43.5.

SizeChartGraphic

Second, subtract half of one European size from this size.

One last word on the topic of shoe stink. Even with leather shoes, you will have some stink. You could wear thin socks, which would help. We wear our shoes barefoot, like most climbers. We spray our shoes after every climbing with the enzyme-based McNett Mirazyme Odor Eliminator and that works well. We pour this into a cheap spray bottle that we bought from Amazon. I think that any enzyme-based pet store odor eliminator would probably also work, although the McNett products are geared toward exercise equipment and maybe they contain specific enzymes.

I hope this helps someone. Climb on!

The best all-purpose snowboard wax

Snowboarders are always getting stuck on the flats and the catwalks. There’s no way around it other than hitching a pole-tow from a skier friend or bringing your own telescoping pole.

But one thing that helps, a lot, is if we have the right wax and don’t scrub speed. I have been waxing my board ever since I started riding. I started out using XXX Adult Snowboard wax, which was this awful glue that probably only sold well to impressionable early-20s males like myself who were trying too hard to look cool. I’ve used rub-on paste waxes, liquid waxes, and fluoro and unfluoridated iron-on waxes. I’ve applied wax using a heat gun based on this cool blog post.

One time, on a dare, I applied KY jelly to the bottom of my board.

After 20+ years of experimentation, I’ve found that black waxes are the ones that work the best across the most conditions.

Black waxes are regular waxes with graphite added. They were originally used for late spring snow, which is covered with pollen. The graphite prevents static cling to the pollen. Because dry powder also behaves like pollen particles, black waxes are excellent on powder days, too. In between the extremes of cold powder days and warm slushy days with pollen, the universal wax base of the black waxes has good glide.

Over the last few years, I’ve been using Swix Moly Fluoro Wax. Although technically a base wax for ski racing, it gives great glide. The toxicity of fluoro waxes bothers me, so I would like to switch to an eco wax if I can. Next season, I’m going to try an eco graphite wax like Purl to see if I can get good enough results.

By the way, the KY jelly was slick for about three minutes. Isn’t that as long as it’s supposed to last?