Fix “#2006 – MySQL server has gone away” Error in phpMyAdmin

I’m importing 3.5MB csv file into the database. After file uploading completed, the following error came out.

#2006 - MySQL server has gone away

It is because MySQL server drop if there is too large packet. To fix the error follow the steps below.

1. SSH to your VPS / Server

2. Edit my MySQL file. Remember to backup your /etc/my.cnf prior to that.

vi /etc/my.cnf

3. Add or edit max_allowed_packet in the MySQL configuration file

max_allowed_packet=16M

4. Save MySQL configuration file

5. Restart mySQL

service mysql restart

If the error still persist you may try to increase the value & try again.


How to Check mod_rewrite Module in Apache/LiteSpeed is Loaded

To check if mod_rewrite Module is loaded in Apache/LiteSpeed follow the following steps

1. For system with cPanel, log to SSH in issue the following commands

/usr/local/apache/bin/httpd -D DUMP_MODULES | grep rewrite

If it return the following, then mod_rewrite is loaded

Syntax OK
rewrite_module (static)

2. For system with no cPanel, check “httpd.conf” file. If the following is in the file then it should be loaded.

LoadModule rewrite_module libexec/apache2/mod_rewrite.so