Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1117
  • Last Modified:

MySql max_allowed_packet

I setup new LAMP VM (has 4Gb ram) and need to restore 9Gb sql file to a database in MySQL.
I configured my.cnf file with

I try to import sql file with 'mysql' command with '--max_allowed_packet' option but failed with below message.

Get a packet bigger than 'max_allowed_packet' bytes.

I figured out the packet size in phpmyadmin but ...

Any suggestion?
  • 4
1 Solution
The default is 1MB,2G is more than the upper limit, max is 1G.
From Mysql documentation:
Command-Line Format       --max_allowed_packet=#
Option-File Format       max_allowed_packet
Option Sets Variable       Yes, max_allowed_packet
Variable Name       max_allowed_packet
Variable Scope       Global
Dynamic Variable       Yes
        Permitted Values
Type       numeric
Default       1048576
Range       1024 .. 1073741824

The maximum size of one packet or any generated/intermediate string.

The packet message buffer is initialized to net_buffer_length bytes, but can grow up to max_allowed_packet bytes when needed. This value by default is small, to catch large (possibly incorrect) packets.

You must increase this value if you are using large BLOB columns or long strings. It should be as big as the largest BLOB you want to use. The protocol limit for max_allowed_packet is 1GB. The value should be a multiple of 1024; nonmultiples are rounded down to the nearest multiple.

When you change the message buffer size by changing the value of the max_allowed_packet variable, you should also change the buffer size on the client side if your client program permits it. On the client side, max_allowed_packet has a default of 1GB. Some programs such as mysql and mysqldump enable you to change the client-side value by setting max_allowed_packet on the command line or in an option file.

The session value of this variable is read only.

Regards, nbhu
I think your setting is too big, so it is invalid and ignored.
This is the dafault setting.
Regards, nbhu
Ken_KimAuthor Commented:
It's only working in session like putty.
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

You can put it in my.ini or my.cnf, so it remains always valid.
We do this on windows, and it is working.
Regards, nbhu
You have to put it in the following section:

# The TCP/IP Port the MySQL Server will listen on

Regards, nbhu
If it's working in a PuTTY SSH session, you're good. There is no way you are going to get a 9GB file through a client like phpMyAdmin.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now