HowtoForge

Creating A Portable MySQL On CentOS 6 And Ubuntu 11.10 Linux From Sources

Creating A Portable MySQL On CentOS 6 And Ubuntu 11.10 Linux From Sources

This tutorial shows how to create a portable MySQL installation on GNU/Linux. It applies to:

At the end of this guide you will obtain a portable MySQL installation on a target directory with its own databases, binaries, logs, pid files, etc.  Consider always the use of a permission preserving packaging (like TAR) for moving the installation between systems or removable storages.

 

Requirements

 

Steps

  1. Define some environment variables to make the installation smoothly:

    $ TARGET=$HOME/mysql
    $ BASEDIR=$TARGET/usr/local/mysql
    $ DATADIR=$TARGET/usr/local/mysql/data
    $ PORT=9797
    $ VERSION=5.5.19

  2. Install cmake, ncurses and bison:
    • On CentOS:
      $ sudo yum install cmake ncurses-devel bison
    • On Ubuntu:
    • $ sudo apt-get install cmake libncurses5-dev bison
  3. Unpack and make (NOTE: mysql-5.5.19.tar.gz is already downloaded in /tmp):

    $ pushd /tmp
    $ tar zxvf mysql-${VERSION}.tar.gz
    $ cd mysql-${VERSION}
    $ cmake .
    $ make

  4. Install into target directory:

    $ mkdir -p $TARGET
    $ make install DESTDIR="$TARGET"

  5. Create system databases:

    $ pushd $BASEDIR
    $ scripts/mysql_install_db --user=$USER \
    --basedir=$BASEDIR \
    --datadir=$DATADIR \
    --ldata=$DATADIR
    $ mkdir -p $TARGET/var/run/mysql
    $ mkdir -p $TARGET/var/log/mysql
    $ popd
    $ popd

 

Post Install Steps

Creating A Portable MySQL On CentOS 6 And Ubuntu 11.10 Linux From Sources