Install MySQL 5.5 From Source (Ubuntu/Linux)

May 16th, 2012 | By: | How to’s, MySQL howto | No comments »

Install MySQL from sourceWhy?…. LOAD DATA LOCAL INFILE?

I recently updated my home machine to Ubuntu 12.04 and found MySQL 5.5 installed as default. As happy as I was to have the latest stable MySQL server, I was a bit gutted to find that LOAD DATA LOCAL was disabled as default, due to security issues. These issues may be valid but this is my local environment and I’ve got projects that require it so thought I’d waste utilize some free time fixing it.

The Process

I’ll be truthful, I did quite a bit of research and didn’t find a definitive guide on how to install MySQL from source, but I aim to provide a guide that gets as close as possible as quick as possible!

Right, lets get on with it shall we….

  1. Firstly, remove any current installations of MySQL server. Open up a terminal and type/copy the following in…
    sudo apt-get --purge remove mysql-server*
  2. Now, we can go ahead and obtain the source files and other packages required to compile and install the source. Type/copy the following into a terminal and press enter…
    sudo apt-get install mysql-source-5.5 build-essential libncurses5-dev cmake
  3. Go to the directory where the source is…
    cd /usr/src/mysql
  4. Un-tar (expand) the source files…
    sudo tar zxvf mysql-source-5.5.tar.gz
  5. Make a directory to store the build files (I personally like to keep them separate, not essential though)…
    sudo mkdir build

    And change to that directory…

    cd /usr/src/mysql/build
  6. Now we need to make the build/installation files using cmake. There are a number of options that you may wish to configure here, these source configuration options can be seen here. You may not need to add any options, you may need to add a load, the only one I needed was -DENABLED_LOCAL_INFILE. Make the build files…
    sudo cmake ../mysql-5.5/ -DENABLED_LOCAL_INFILE=1
  7. Now install the build we just made…
    sudo make install
  8. Copy service file to correct location…
    sudo cp support-files/mysql.server /etc/init.d/mysql
  9. Start the MySQL Server…
    sudo service mysql start

MySQL 5.5 should now be installed with LOAD DATA LOCAL INFILE enabled.

WARNING

These are pretty simple steps in themselves but it may not necessarily end here.

If you already had an installation your data directory and configuration file (my.cnf) should remain untouched. But you may have to look into the source configuration options to connect to your current setup (specifically -DMYSQL_DATADIR for your data directory and -DSYSCONFDIR for your my.cnf)

If this is a new installation you still have a few steps, included in the MySQL Post installation Procedures.

 

As usual, any questions please comment with your errors and we’ll see what we can do. Good luck!