Home PHP JavaScript CSS WordPress APIs .htaccess Other How-To Useful Scripts What I Recommend
Posted on by Aleksandar Gichevski ()
Recently I was working on a script that is doing parallel operations and working with large amount of data records, counted in millions. After building it I did some tests with smaller amount of data and all was fine and working smoothly. I was happy that after lot of hard work and spent hours my script was doing what is was supposed to do. I uploaded the script on dedicated server, modified to use the large data and then BUM! Nothing happened, the script was not working. It was working few minutes before hmm.. After debug on the code I got error writing file /tmp (errcode 28). This error was causing my sql commands not to work properly and that's why the script was broken. On server /tmp partition was 2GB of space but it seems, that was little space for the information that my parallel script was allocating during execution. If you want to learn more about Linux partition read this nice tutorial that will give u briefly information to understand how everything works.

How To Fix error writing file /tmp

If you are working on already live system place your site in maintenance mode. Click here to find out more how you can do this using .htaccess This fix that I'm going to explain below is only if your error is caused because allocated MySQL data. There are 2 ways how you can fix this error:

Re-arrange your server space (Not Recommended)

If you use dedicated server contact your hosting company and ask them to create larger /tmp partition and rearrange your server space. This is not recommended because there will be server downtime and add the time that your support should answer and execute the request then u will wait for 2 days this to be completed.

Create new directory on other bigger partition for mysqltmp (Recommended)

This is the way I solved this error and it was instant solution. Follow below steps to create new directory for temporary mysql information. I have chosen /home directory because in 99% of the servers it is located in the biggest partition: Step 1 - Login to your server using SSH, you can use Putty Step 2 - Enter below commands to create a directory:
mkdir /home/mysqltmp
chown mysql:mysql /home/mysqltmp
Step 3 - Open /etc/my.cnf using nano or pico and add following under [mysqld]
tmpdir=/home/mysqltmp
Step 4 - Now restart MySQL

Confirm that you have solved this error

After completing steps above enter:
mysqladmin variables|grep tmpdir
You should see this:
# mysqladmin variables|grep tmpdir
| tmpdir | /home/mysqltmp |
#
That's it, the issue Error writing file /tmp has been solved.

Other Posts You Might Like

Get a fast, free website audit

Enter your URL below to get full in-depth SEO report and tips.

‚Äč

Useful Scripts

Most Popular Posts

Recent Posts

June 14th, 2014
Website Optimization Using Gzip Compression

June 10th, 2014
Google Search AutoComplete API

May 14th, 2014
What is a Tag Cloud and How to Calculate it by Formula

March 27th, 2014
Error writing file /tmp (errcode 28) Solved!

February 15th, 2014
Fixed CSS & HTML Navigation Bar

February 9th, 2014
Benchmark Your Server (CPU, File IO, MySQL) with SysBench

February 8th, 2014
JavaScript Array Basics

January 29th, 2014
JVZoo IPN API in PHP

January 25th, 2014
Payoneer Debit Card for Freelancers to receive money online

January 24th, 2014
How HTML Color Codes are generated?

Read Latest Posts directly on Facebook

Archive

X

Get a fast, free website audit

Enter your URL below to get full in-depth SEO report and tips.