Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm getting a weird message from phpmyadmin saying:

#2006 - MySQL server has gone away

What I found online is that I should increase the size of max_allowed_packet witch should be in the my.conf file witch is located at /etc/my.cnf. Untill now everything is fine, but the problem is that this file does not contain what I need.

Here is the content of the .cnf file on my server:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Where should I look in order to increase the size of the packet? I'm new in the linux world and I'm lost.

share|improve this question

migrated from stackoverflow.com Jul 16 '13 at 8:51

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 2 down vote accepted

You need to change the my.cnf file to include the single line under [mysqld] in your file

max_allowed_packet=16M

now restart the MySQL service and you are done.

You can see its current value in mysql like this:

SHOW VARIABLES LIKE 'max_allowed_packet'

You can try changing it like this, but it's unlikely this will work on shared hosting:

SET GLOBAL max_allowed_packet=16777216;

Also please read this: http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html

share|improve this answer
    
Worked!!! Thanks for your help! –  Slim Jul 16 '13 at 8:30
1  
@Slim You'r Welcome :) –  Sathish D Jul 16 '13 at 8:31

You can set the limit to (for example) 8M

mysql> set global max_allowed_packet=8M
share|improve this answer
    
I already tried it, Then I restarted MySQL, nothing happened. I restarted the whole server, but the issue remains :( –  Slim Jul 16 '13 at 8:22
    
That's because setting server variables with SET GLOBAL doesn't persist on MySQL restart. You can use it to set a variable without restarting MySQL, but to make it persist you have to put in my.cnf as well. –  redguy Jul 17 '13 at 10:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.