You are here: HomeProjectsSeries 2 - Project and Product ManagementSeries 2 : MYSQL ERROR 1148 (42000) : The used command is not allowed

Series 2 : MYSQL ERROR 1148 (42000) : The used command is not allowed


100018In previous parts, of Series 2, data has been loaded into the database, from a text file, using the MYSQL statement:


 As it turns out using this statement is probably not the best way to load data into the database as it can lead to a series of errors, as we found out below.

The LOAD DATA INFILE statement appeared to have worked well and just when things were becoming interesting a few cracks began to emerge. Firstly, when attempting to add some new items to the things to do to tablettd, we got the following error message. 

ERROR 13 (HY000): Can't get stat of '/var/lib/mysql/ttd_entries.txt' (Errcode: 2)

Now, after seeing the number of pages, on Google, a search for this error  produces we were encouraged enough to believe that a solution would be quite easily found. Hmm, wishful thinking!  

A solution proposed on some websites is to do with AppArmor, which prevents MYSQL from accessing the text file. The AppArmor solution proposed to solve the issue was to fire up a text editor like Emacs

sudo emacs /etc/apparmor.d/usr.sbin.mysql

and add the line /tmp/** rwk,  Then, restart the AppArmor application using the following command

sudo /etc/init.d/apparmor reload

Unsurprisingly, that didn't work and we still had the same error when trying to enter text into the database from a file. The next piece of invaluable advice was to check the MYSQL configuration file, to find the location of MYSQL databases. The file, my.cnf, should either be located in the /etc or /etc/mysql directories. On our system it is located in the latter location. 

A check of the location of the MYSQL database storage directory showed it to be /var/lib/mysql, which implies that databases are stored as /var/lib/mysql/database_name. The temp directory was correctly set to /tmp. Hence,  everything appeared to be located, to us, where it should be. However, performing this exercise allowed us to confirm that we did not have access rights to this directory, which seemed to be the problem.

Hence, further search results suggested the ridiculous, as a solution to not having access rights, like to chmod 777 the directory, /var/lib/mysql, which is equivalent to placing a large banner outside your house saying "I leave my windows and doors unlocked, all the time. Please rob me!". For security reasons the /var/lib/mysql directory is owned by mysql (and possibily root) and should only be owned by MYSQL!

Another suggestion, that this time seemed reasonable, was to alter the MYSQL statement to the following


which, presumably, has the effect of using a local directory for storage and not a directory that we do not have access to. Using this MYSQL statement produced the following error.

ERROR 1148 (42000): The used command is not allowed with this MySQL version

Crumbs! Just when we thought things couldn't get any worse we ended up with another error and more Google search page results to trundle through. Well, to cut a long story short (we know you good folk have better things to do and just want the solution) apparently the MYSQL variable LOAD DATA LOCAL INFILE is disabled on some systems, on either the server or client. When this is the case the client receives the ERROR 1148 above. 

Now, although this sounded promising the suggested solutions were not. In the end we used a combination of the proposed solutions without sucess, until we tried starting MYSQL in the following way

$ mysql --local-infile=1

and like magic it worked, we can now load data into the database again. Now, the next thing to do is to find out how to permanently enable this variable in the database.

Go to comments start