Posts Under Category: cPanel

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

By default all MySQL database on a server is saved in /var/lib/mysql directory. If you don’t have enough space left in /var directory or if its filling up quickly, you can move your MySQL directory to /home partition.

Assuming you have enough space in /home partition, follow below steps to move MySQL to a new location in /home/var_mysql directory.

Login in server as root via SSH and run following command:

mysqldump --all-databases | gzip > /home/alldatabases.sql.gz
/etc/init.d/mysql stop
mkdir /home/var_mysql
mv /var/lib/mysql /home/var_mysql
chown -R mysql:mysql /home/var_mysql/mysql
ln -s /home/var_mysql/mysql /var/lib/mysql
/etc/init.d/mysql start

Done!!!
You should now have your MySQL at a new location /home/var_mysql

Explanation of above commands

mysqldump --all-databases | gzip > /home/alldatabases.sql.gz

This will create a full backup of all MySQL database. If anything goes wrong, you can restore all MySQL database using this backup file. Name of this file will be alldatabases.sql.gz and it will be saved in /home directory.

/etc/init.d/mysql stop

This will stop mySQL.

mkdir /home/var_mysql

This will create a new directory var_mysql in /home

mv /var/lib/mysql /home/var_mysql

This will move /var/lib/mysql to /home/var_mysql

chown -R mysql:mysql /home/var_mysql/mysql

This will give ownership of /home/var_mysql/mysql directory to user mysql.

ln -s /home/var_mysql/mysql /var/lib/mysql

This will symlinking the old /var/lib/mysql to the new location.

/etc/init.d/mysql start

This will start the MySQL.

What if anything goes wrong

We have create a full MySQL backup in our first step. If anything goes wrong, you will always have the full mysql backup to restore all database. Please refer to below tutorial to restore your databases using the full MySQL backup file.
http://www.lophost.com/tutorials/ssh/how-to-create-and-restore-mysql-backup-of-all-accounts/

Our Recommended Dedicated Server

Error_log file saves the error logs of a account / user / website. There can be multiple error_log file under one user / account / website.

These error_log files may consume lots of space on your server. Sometimes the size of error_log files are in GB. So, you may want to delete all error_log files to free up some space on server.

Login in server via SSH as root and execute following command:

find /home -type f -name error_log -exec rm -f {} \;

The above command will search for error_log files in /home directory and delete them. Thus it will delete all error_log files under all users / accounts / cPanel accounts / websites.

Note:

1) This command can take lots of time to complete depending on size of your /home directory. Sometimes it may take 10-30 minutes to complete.

2) If required server will automatically create new error_log files.

Our Recommended Dedicated Server

Normal price of cPanel/WHM license for dedicated server is 25$ per month, while cPanel/WHM license for VPS is around 10$ per month.

So, what is difference between cPanel / WHM for dedicated server and cPanel / WHM for VPS??

Don’t be confused that VPS cPanel/WHM lacks few functionality. Both cPanel for VPS and dedicated server are functionally identical. VPS cPanel/WHM name is VPS Optimized and name of cPanel/WHM for dedicated server is Accelerated.

The only difference is that VPS Optimized is optimized for virtual environments.

Our Recommended VPS Hosting