Install MySQL 5.5 From Source (Load Data Local Infile Issues?)


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. 


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

If you already have 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 after those below, they are included in the MySQL Post installation Procedures.

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…
  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…
  3. Go to the directory where the source is…
  4. Un-tar (expand) the source files…
  5. Make a directory to store the build files (I personally like to keep them separate, not essential though)…

    And change to that directory…
  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…
  7. Now install the build we just made…
  8. Copy service file to correct location…
  9. Start the MySQL Server…

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


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


  • Joshua

    Very useful, we ran into the same problem as you: needing LOAD DATA LOCAL INFILE and realizing it was not compiled in. One suggestion, put your warning about doing a fresh installation at the top of this article. ?

  • Duly noted! (I’ve moved the warning to the top).
    After finding and performing these steps something happened where my MySQL installation was updated through the repos! I ended up changing “LOAD DATA LOCAL INFILE” to “LOAD DATA INFILE” but the file name has to be a full path, using PHP I used realpath().

    In some situations though you won’t be able to change that and you will have to disable updating of this package.

  • Cornstalk

    The MySQL 5.5 documentation says (1) that the binaries ship by with LOAD LOCAL enabled by default; (2) that the option only affects the client and that LOAD LOCAL can be enabled on the server by specifying -local-infile at server startup; and (3) that LOAD LOCAL can be enabled on the command line client, so long as the compilation enabled LOAD LOCAL, by specifying -local-infile at invocation. I am not sure about other mysql clients, but my understanding is that on most, e.g. PHP’s PDO interface, it is possible to use the client with LOCAL INFILE and the default MySQL compilation.

    Therefore, I believe the above report to be completely bogus, and that Ubuntu users desiring to use LOAD LOCAL should carefully consult their MySQL documentation before they adopt the radical remedy of recomiling mysql from source.

  • I did try enabling -local-infile at invocation and my.cnf to no avail! hence the ‘radical remedy’ of recompiling!

    To be honest it wasn’t radical. Obviously anybody doing something like this shouldn’t go ahead and try it on a production server installation without even testing it in a staging environment but that goes without saying.

    People shouldn’t be put off compiling source though. It’s not as much work as it looks and can offer significant benefits…. if done correctly. But if you are testing its a matter of trial and error.

    Like Cornstalk says though, always check the documentation. But I’m guessing if you got to this page through Google you weren’t too pleased with the documentation!


    sorry have an error message: — Installing: /usr/local/mysql/docs/INFO_BIN
    CMake Error at cmake_install.cmake:58 (FILE):
    file INSTALL cannot find “/usr/src/mysql/mysql-5.5/Docs/INSTALL-BINARY”.

    Would you please help? Many thanks in advance!

    • tetris eleven

      Hi, it looks like you are using a newer mysql source.

      1. Remove all files and folders in the /usr/src/mysql/ directory (except the .tar file)

      2. Go into synaptic and unselect the current mysql-source package.
      Apply changes. Then select the mysql-source-5.5 package again, click on Package-> Force Version, and pick the lowest one there. Apply changes.

      3. Then proceed from Step 3

      • Federico Reggiani

        And what if Im working from command line in a server? How to force version?

        • Kesi

          Creating an empty file there will get rid of that error:
          # touch /usr/src/mysql/mysql-5.5/Docs/INSTALL-BINARY

    • Tim Dunkley
    • Kesi

      Creating an empty file there will get rid of that error

      # touch /usr/src/mysql/mysql-5.5/Docs/INSTALL-BINARY

  • Federico Reggiani

    I downloaded mysql 5.6.11 (5.5 is unavailable). Compiled and moved to init.d but I get a unrecognized service when I try to start it,
    Any help?

    • FFly

      Did you solved the “unrecognized service” problem? I got the same error message following the steps.

  • Pingback: MYSQL. 5.5 > . Installation from source Ubuntu | BlogoSfera()

  • Miloš Ilić

    I have an error:

    sudo service mysql start

    Starting MySQL

    * Couldn’t find MySQL server (/usr/bin/mysqld_safe)