Installing MariaDB and Updating PHP on Yosemite

Continuing from my previous post about updating Apache.

Why MariaDB and not MySQL? See this interview with Michael Widenius, founder of both MySQL and MariaDB.

O. Clean up borked MySQL install

My first attempt to install MySQL via homebrew led to various errors and whatnot, so I uninstalled it via brew uninstall mysql. It turns out that this alone won’t completely cleanup the installation, so first I needed to clean out the remaining files:

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo [emacs/nano/vi] /etc/hostconfig (Remove line MYSQLCOM=-YES)
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
sudo rm -rf /tmp/mysql.sock

After all this, I checked to see whether it was running:

ps -ax | grep mysql

and it was!

9958 ttys000 0:17.58 mysqld
11576 ttys002 0:00.00 grep mysql

Kill the process with

kill -9 {PID} - in this case, 9958

During the process of tracking down all this info, I found the interview with Michael Widenius and decided to go with MariaDB. Now we’re ready!

1. Install MariaDB:

brew install mariadb
unset TMPDIR

That will take you through the process of removing anonymous users, setting up a root password and user, etc.

Then just:
mysql -uroot to log in.

2. Upgrading PHP

Yosemite comes with PHP 5.5 installed. As of this writing, the latest stable version of PHP is 5.6.2. There are a couple of ways to upgrade, one involving Homebrew/MacPorts and other using a script provided by Marc Liyanage. Since I’ve installed/upgraded everything else via Homebrew, I’m going to continue on that road.

First, enable some additional taps:

brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew tap homebrew/versions

I then used the following command to install PHP 5.6:

brew install php56 --homebrew-apxs --with-apache --with-homebrew-curl --with-homebrew-openssl --with-phpdbg --with-tidy --with-homebrew-libxslt --without-snmp

Please note that the –without-snmp arg is recommended by Homebrew due to a bug with –with-homebrew-openssl, which is current as of 30 October 2014.

Ensure that the correct PHP is being used on the command line by adding the following to .bash_profile:

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

To start PHP 5.6 at login:

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents


StackOverflow discussion on removing MySQL from MacOSX

Homebrew-PHP repository notes

–without-snmp bug discussion

This entry was posted in local.config and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *