3

I am trying to import a mysql file to my cpanel phpmyadmin. But I am getting this error message. "#1153 - Got a packet bigger than 'max_allowed_packet' bytes"

I have tried putty as well. But the error message is same. I don't know how to change the mox upload size in mysql in cpanel.

Please help me

Thank you so much

2
  • file size is around 4.6mb if that is sql.gz
    – Theepan K.
    Apr 2, 2012 at 18:02
  • if just .sql then the size is 46mb
    – Theepan K.
    Apr 2, 2012 at 18:03

4 Answers 4

12

This error has nothing to do with the php.ini, its clearly an error message from the DBMS.

You can increase the value of the max_allowed_packet in the my.cnf file:

[mysqld]
max_allowed_packet = 128M

After restarting your mysqld it should work (for larger data increase the value more)

If you try to "import with putty", i guess your are using mysql from command line, in this case you can start mysql with the --max_allowed_packet parameter e.g:

mysql --max_allowed_packet=128M -u root -p sampledb < dump.sql

Alternatively if you source the file from within a running mysql session you can set the parameter by:

set global max_allowed_packet=128M;

last example only is effective till next restart of mysqld, for a permanent solution stick to my first example.

3
  • Yes You are correct. It is not a problem with php.ini. How do i locate this my.cnf file?
    – Theepan K.
    Apr 2, 2012 at 18:04
  • I tried this mysql --max_allowed_packet=128M -u root -p sampledb < dump.sql example. But the error message is same :(
    – Theepan K.
    Apr 2, 2012 at 18:11
  • @the my.cnf file is usually in /etc/ on linux systems. Can you do the following in mysql: show variables like 'max_allowed_packet'? As which user you connect to the database?
    – Flo Doe
    Apr 2, 2012 at 18:23
3

php -i | grep php.ini

Open the Loaded php.ini and modify "upload_max_filesize" and restart Apache (assuming u have apache)

2
  • Thank you. Yes I have Apache. But all those are in cpanel? I mean php.ini and restarting options?
    – Theepan K.
    Apr 2, 2012 at 17:57
  • @user1080319 if you using shared hosting, that can be the problem to change that settings.
    – safarov
    Apr 2, 2012 at 18:04
0

The fix is to increase the MySQL daemon’s max_allowed_packet. You can do this to a running daemon by logging in as Super and running the following commands.

# mysql -u admin -p

mysql> set global net_buffer_length=1000000;
Query OK, 0 rows affected (0.00 sec)

mysql> set global max_allowed_packet=1000000000;
Query OK, 0 rows affected (0.00 sec)

Then to import your dump:

gunzip < dump.sql.gz | mysql -u admin -p database
0

Setting these values in php.ini solved my problem:

php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.