Fixing MySQL error 29 (ErrCode: 13) in Ubuntu

Ubuntu 12.04 Recently I had to work with a large amount of data that had to be imported into MySQL via a script after being modified. I’ve found that using LOAD DATA was the quickest way to do the job.

If you are using Ubuntu for your server (or you have to work with a server using Ubuntu) you will find this error when trying to use the query:

ERROR 29 (HY000): File '....' not found (Errcode: 13)

After few seconds on Google you will find many users that managed to get over the error using the keyword LOCAL, but if you keep your MySQL updated you will see that it will not work as it could generate a security issue in your server.

To overcome this issue there is a simple workaround that require you to modify the MySQL’s AppArmor file and define directory where the program can read and write.

Be aware that allowing MySQL to read and write in a directory could lead to security problems, always review this kind of changes with a System Administrator.

The workaround is really quick:

  1. Open the file /etc/apparmor.d/usr.sbin.mysqld as root with your favourite text editor
  2. You should see a list of paths where AppArmor allow MySQL to write and read, at the end of this list add the directory where you would like that MySQL will be able to read and write following the pattern used in all the previous entries. For instance:
    #Other contents
    /usr/sbin/mysqld {
        #Other contents
        /var/log/mysql.log rw,
        /var/log/mysql.err rw,
        #Other contents
        #This will be your dir definition
        /tmp/ r,
        /tmp/* rw,
        #Other contents

    Then save and close the file.

  3. After you have successfully modified the file it is time to tell AppArmor that it needs to reload the configurations, so as root execute the following command:
    # /etc/init.d/apparmor reload
  4. Then restart MySQL, as root execute the following command:
    # service mysql restart

At this point you have allowed MySQL to write and read contents into your defined directory, only do this if you know what you are doing! I take no responsibility for any damage or data loss caused by a server not correctly secured.

Be careful & have fun!


Change Thunderbird default browser in XFCE

XFCEI had to change the default browser in Thunderbird but there was no clear way to do that, recently I found the solution.

I’ve tried to update the alternatives with

update-alternatives --config x-www-browser

but it just got ignored, the solution is to change the settings in Thunderbird’s config editor (Preferences > Advanced > Config) and search for network.protocol-handler.warn-external.http and network.protocol-handler.warn-external.https and set them to true, this will ask you what browser Thunderbird should use to open the links, just check “remember the setting” and set your preferred browser.


Who use linux systems may encounter the following error:

W: GPG error: testing Release:       
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB563F93142986CE

W: There is no public key available for the following key IDs:      

The ID is different everytime but the solution is always the same:

# gpg --keyserver --recv-key YOURSEGNALEDID
# gpg -a --export YOURSEGNALEDID | sudo apt-key add -



Drupal SA-CORE-2012-003 quick fix

Drupal Recently Drupal released the new version (7.16) to fix a security issue that would allow an attacker to reinstall an existing Drupal site with an external database server and then execute custom PHP code, more information available here:

There are many way to prevent this instead of updating a Drupal installation (always recommended), probably the quickest is to deny access to the interested file with few lines for the .htaccess file:

<Files install.php>
  deny from all
  ErrorDocument 403 "Access denied."


Vodafone key on ubuntu 12.04

Ubuntu 12.04 Recently I had to connect to internet using the Vodafone Key from the Vodafone station, here a brief guide about how to do it quickly:

1) Click on the icon that manage the network connections and select “Edit connections”
2) Select “Mobile Broadband”
3) Click on “Add”
4) Now you should see your Internet key connection, select “Modify”
5) Your vodafone APN is

That is, this mainly apply to users from Italy.

How to solve Gtk-WARNING about “pixmap”

Ubuntu 11.10If you are running Ubuntu 11.10, some applications my generate the following error:

Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",

How to solve that?

Easy, install gtk2-engines-pixbuf!

From shell you may run:
sudo apt-get install gtk2-engines-pixbuf

Type your password and get it done in few seconds.


SSH/Shell update Drupal from a minor version to another

Drupal Hello everyone,
last day I had to update Drupal 7.10 to the most recent at the moment (7.12), I never did something like that so I was like “here we go, 1 work day that will go burned! :D”, but thanks to the Drupal community I was able to update the installation.

Since isn’t very easy at first (reading UPGRADE.txt was not helpful unfortunately), therefore here a quick list of the steps:

  1. Put your site into maintenance mode or close accesses from the outside.
  2. First of all, backup your installation folder (usually a rsync -av startfolder destinationfolder, or a cp -a startfolder destinationfolder will do the job just fine)
  3. Then you have to backup your database (you can do it all in one step using screen, but I bet that if you are reading this and you are experienced you already know that), depending if you are running MySQL or PostgreSQLthe instructions changes, but I think could be sum up as follows:
    • MySQL: mysqldump -uUser -pPassword -hHost dbname > dumpname.sql
    • PostgreSQL: pg_dump databasename > dumpname.sql

    If you use PostgreSQL you need to remember that the operations have to be done with the correct user. Refer to the documentation for further details.

  4. After you have done the backups, reach your site root folder and create a folder to hold the new Drupal version, something like mkdir upgrade, then enter inside it with cd upgrade.
  5. Download the archive with wget
  6. Open the archive with tar -xzvpf drupal-7.12.tar.gz.
  7. Then enter the newly created directory like we did before, cd drupal-7.12.
  8. At this point we have all that we need, this step is the actual upgrade, we have to move some files in the root directory, assuming you followed this steps, the command you need is the following:
    rsync -av CHANGELOG.txt COPYRIGHT.txt cron.php includes index.php INSTALL.mysql.txt INSTALL.pgsql.txt install.php INSTALL.txt LICENSE.txt MAINTAINERS.txt misc modules profiles scripts themes update.php UPGRADE.txt xmlrpc.php ../../
  9. After you have done that, should be an instant action, open your browser and go to your website URL and add a /update.php at the end, you should have
  10. Follow the instruction on-screen to complete the update process on the database, don’t change anything from the dropdowns.
  11. Once the update is complete you may remove the directory we created to download and extract drupal.

Is not very short but is all you need to do.