Skip to content

Instantly share code, notes, and snippets.

@iwata
Forked from arisawa/mqh_install.sh
Last active October 13, 2015 11:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iwata/4187300 to your computer and use it in GitHub Desktop.
Save iwata/4187300 to your computer and use it in GitHub Desktop.
Installing MySQL5.1 / Q4M / HandlerSocket@Mavericks
#!/bin/sh
set -xe
if [ `which perl` = "/usr/bin/perl" ]; then
echo -n -e "\e[1;31mUSING SYSTEM PERL OK? [y/n]\e[m: "
read ANSWER
if [ "$ANSWER" != "y" ]; then
exit 255
fi
PERL_CPANM_OPT="$PERL_CPANM_OPT --sudo"
fi
### MySQL
echo -e "\e[1;32mStarting MySQL5.1 installation.\e[m"
brew install gdbm libtool automake
brew tap homebrew/dupes
brew install apple-gcc42
brew tap homebrew/versions
env LC_CTYPE=C LANG=C NOLOCALE=1 CC=`which gcc-4.2` CXX=`which g++-4.2` brew install mysql51 --with-utf8-default
brew unlink mysql51
brew link mysql51 --force
MYSQL_VERSION=`mysql -V |awk '{print $5}'|sed 's/,//'`
mysql_install_db --basedir=/usr/local/Cellar/mysql51/$MYSQL_VERSION
echo -e "\e[1;32mInstalled MySQL $MYSQL_VERSION\e[m"
mysql.server start
echo -e "\e[1;32mLaunchctl load MySQL.\e[m"
cp /usr/local/Cellar/mysql51/$MYSQL_VERSION/homebrew.mxcl.mysql51.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql51.plist
### reinstall DBD::mysql
curl -fsSL http://xrl.us/cpanm | perl - --reinstall -n DBD::mysql
### extract mysql tarball
[ -r /tmp/mysql51-$MYSQL_VERSION.tar.gz ] || cp `brew --cache`/mysql51-$MYSQL_VERSION.tar.gz /tmp
cd /tmp
[ -d mysql51-$MYSQL_VERSION ] || tar xfz mysql51-$MYSQL_VERSION.tar.gz
### Q4M
Q4M_VERSION=0.9.13
echo -e "\e[1;32mStarting Q4M installation.\e[m"
cd /tmp
[ -r q4m-$Q4M_VERSION.tar.gz ] || curl -O http://q4m.kazuhooku.com/dist/q4m-$Q4M_VERSION.tar.gz
[ -d q4m-$Q4M_VERSION ] || tar zxf q4m-$Q4M_VERSION.tar.gz
cd q4m-$Q4M_VERSION
env CC=`which gcc-4.2` CXX=`which g++-4.2` ./configure --prefix=/usr/local/Cellar/mysql51/$MYSQL_VERSION --with-mysql=/tmp/mysql-$MYSQL_VERSION CFLAGS="-I/usr/local/Cellar/mysql51/$MYSQL_VERSION/include/mysql" CPPFLAGS="-I/usr/local/Cellar/mysql51/$MYSQL_VERSION/include/mysql"
make && make install
mysql -u root < support-files/install.sql
mysql -u root -e 'show plugins'
# perl run_tests.pl
### HS
echo -e "\e[1;32mStarting HandlerSocket installation.\e[m"
cd /tmp
[ -d HandlerSocket-Plugin-for-MySQL ] || git clone -q git@github.com:DeNA/HandlerSocket-Plugin-for-MySQL.git
cd HandlerSocket-Plugin-for-MySQL
git pull origin master
brew install libtool autoconf automake
./autogen.sh
env CC=`which gcc-4.2` CXX=`which g++-4.2` ./configure --with-mysql-source=/tmp/mysql-$MYSQL_VERSION --with-mysql-bindir=/usr/local/Cellar/mysql51/$MYSQL_VERSION/bin --with-mysql-plugindir=/usr/local/Cellar/mysql51/$MYSQL_VERSION/lib/mysql/plugin
make && make install
mysql -u root -e "install plugin handlersocket soname 'handlersocket.so'"
mysql -uroot -e 'show plugins'
#cd perl-Net-HandlerSocket
#curl -fsSL http://xrl.us/cpanm | perl - .
### finish
echo -e "\e[1;32mdone.\e[m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment