Posts Under Category: tmp

This tutorial explains how you can change or move MySQL /tmp directory to a new location on a server / VPS. Login as root to your server via SSH.

Step 1: Open /etc/my.cnf file for editing

nano /etc/my.cnf

Step 2: Add below line under the [mysqld] section and save the file.

tmpdir=/home/mysqltmp

To save file press: Ctrl + O
To exit from nano editor press: Ctrl + X

This will set new location of MySQL tmp to /home/mysqltmp. You may change to any different location.

Step 3: Create new directory

mkdir /home/mysqltmp
chmod 1777 /home/mysqltmp

Step 4: Restart MySQL

/etc/init.d/mysql restart

Step 5: Check new location

mysqladmin var | grep tmpdir

This should show following return.

| slave_load_tmpdir                       | /home/mysqltmp
| tmpdir                                  | /home/mysqltmp

Done!!

Our Recommended Dedicated Server

Many server / VPS have very small /tmp partition like 500 MB. It is recommended to have /tmp partition of minimum 2GB.
If you server is facing issue of /tmp partition filling-up quickly, here is how you can increase its size.

This tutorials explains how easily you can increase size of /tmp partition on a cPanel server / VPS.
Login as root via SSH to your server, and follow below steps / commands.

Step 1: Stop services

Before you start resizing, you should stop cpanel, apache and mysql. Run following command to stop these services

/etc/init.d/cpanel stop
/etc/init.d/httpd stop
/etc/init.d/mysql stop

Step 2: Umount /tmp and /var/tmp

umount -l /tmp
umount -l /var/tmp

Step 3: edit /scripts/securetmp

vi /scripts/securetmp

And change value of my $tmpdsksize For making size of /tmp partition to 2GB change its value to 2048000. After making change save this file. It should be like this:

$tmpdsksize = 2048000

Step 4:Run these commands to resize /tmp partition

rm -fv /usr/tmpDSK
/scripts/securetmp

Step 5: Start services

/etc/init.d/httpd start
/etc/init.d/mysql start
/etc/init.d/cpanel start

Done!!! The /tmp partition on your cPanel server is now of 2GB

This tutorial is applicable only for cPanel Server / VPS

Our Recommended Dedicated Server