sql error(2007) Malformed packet

[expired user #7277]'s profile image [expired user #7277] posted 11 years ago in Import/Export Permalink
I have HeidiSQL 8.0.0.4530 installed on both my computers.

When importing a CSV file on my laptop running Windows 7 Starter 32 bit operating system, the file did not upload into the database.

The system responded with the following message
sql error(2007) Malformed packet

I then imported the CSV file on my desktop computer running Windows XP professional Version 2002 Service Pack 3


Is there some setting that I need to make on my Windows 7 laptop computer to avoid this error?

Thanks
[expired user #7277]'s profile image [expired user #7277] posted 11 years ago Permalink
Forgot to mention information about MySQL

Server version: 5.5.32-cll - MySQL Community Server (GPL)
Protocol version: 10
jfalch's profile image jfalch posted 11 years ago Permalink
did you (or heidisql via import) use LOAD DATA LOCAL INFILE ? if so, has your serverĀ“s my.ini, [mysql] section,
local-infile=1 ? has to be explicitly enabled)
[expired user #7277]'s profile image [expired user #7277] posted 11 years ago Permalink
The LOAD DATA LOW_PRIORITY LOCAL INFILE was used

I made a typo on the error number- should be 2027
/* SQL Error (2027): Malformed packet */

unable to locate the my.ini file
ansgar's profile image ansgar posted 11 years ago Permalink
Is that error reproducible? Looks more like a one-time error to me.
ansgar's profile image ansgar posted 11 years ago Permalink
Just getting exactly the same error here, on a local MySQL 5.5.8 server. wtf...
ansgar's profile image ansgar posted 11 years ago Permalink
As an alternative in HeidiSQL, you can always use the "Method": "Client parser". I had introduced that alternative for users which lack the privilege to fire a LOAD DATA command. When chosing "Client parser", HeidiSQL goes through your CSV file itself, and generates extended INSERTs.
[expired user #7277]'s profile image [expired user #7277] posted 11 years ago Permalink
Been getting the error on 5 plus attempts using the laptop with Windows 7. Have not been able to import yet

Always works with Windows XP

Will try the Client parser alternative
Thanks
ansgar's profile image ansgar posted 11 years ago Permalink
Shit... just found out the newer libmysql.dll I recently committed is causing this "malformed packet" error. See issue #3262.
ansgar's profile image ansgar posted 11 years ago Permalink
Seems to be a HeidiSQL issue, as I can fire the same LOAD command on the command line, using the same libmysql.
ansgar's profile image ansgar posted 11 years ago Permalink
* Reverting libmysql to MariaDB's v5.5.2 fixes this issue, but would break again a disconnect problem mentioned here.
* Using a libmysql from a MySQL (not MariaDB) server would most probably break pluggable authentication on MariaDB.

hmm... what code in HeidiSQL could cause this mess?
Code modification/commit 0e02e6c from ansgar.becker@gmail.com, 11 years ago, revision 8.0.0.4531
Update libmysql again with a version from MariaDB 5.5.33a. Fix SQL error 2027 "malformed packet", when firing LOAD DATA command. See http://www.heidisql.com/forum.php?t=13454 and issue #3262.
ansgar's profile image ansgar posted 11 years ago Permalink
Seems the current stable of MariaDB's libmysql (5.5.33 plus the "a" release also) does not have that "Malform packet" issue. Nothing in the changelog about that though.

r4531 exchanges the v5.5.32 to v5.5.33a .

There is a chance that pluggable authentication is broken again, so we need to wait for feedback in issue #3262. Just a gutt feeling, as HeidiSQL just reads "6.0.0" out of that libmysql now, even without "MariaDB" prefix.
ansgar's profile image ansgar posted 11 years ago Permalink
Sorry for all the mess. r4532 fixes all issues here. Using a libmysql from MariaDB 5.3.12 now. And
* it's a 32 bit version (using a 64bit .dll in a 32bit executable was quite embarrassing...)
* it supports pluggable authentication
* finally it does not have the "malformed packet" in the LOAD DATA LOCAL INFILE command
[expired user #5700]'s profile image [expired user #5700] posted 10 years ago Permalink
Just downloaded the lastest build - 8.3.0.4851 64bit.

Our malformed packet friend when importing a csv seems to have returned.

It worked fine using Method:Client Parses File, but using Server I get the malformed packet.

Looking at the logs, v4827 included a refreshed libmysql.
ansgar's profile image ansgar posted 10 years ago Permalink
Googling around I get the impression that both the client and server must have "enable-local-infile" activated. Is that the case on your server?
[expired user #5700]'s profile image [expired user #5700] posted 10 years ago Permalink
The server has the variable set "local_infile = ON" (this has always been the case as far as I know).

The server runs scripts that load csv files every day, and I also load csv files on a regular basis when testing things, and never had problems (apart from with the newer version of libmysql).
ansgar's profile image ansgar posted 10 years ago Permalink
Ok, then we have two conflicting issues here: The old libmysql does not support the utf8mb4 charset, which HeidiSQL makes use of since recently. The newer libmysql crashes when firing a LOAD DATA command.

I tend to keep the newer libmysql, for the benefit of having utf8mb4. The CSV import can always be done with the "client" method, and we cannot ignore all coming updates for libmysql.
[expired user #5700]'s profile image [expired user #5700] posted 10 years ago Permalink
If it helps:

The tables I have are a mix of latin1_swedish_ci and utf8_general_ci formats.

In this case, the one I was loading into was latin1_swedish (i've not looked to see if uft8_general is different, but I've not had problems in the past).

The file being loaded was ASCII / PC / ANSI.

ansgar's profile image ansgar posted 10 years ago Permalink
Is it probably this bug in MySQL? http://bugs.mysql.com/bug.php?id=72107
ansgar's profile image ansgar posted 10 years ago Permalink
I see that on my localhost server, when I leave that "LOCAL" away from the LOAD DATA command, my imports work just fine. They take quite a long time on small files, but they work. But that surely does not work on remote servers, as the local files are not found there. Why's that so tricky?
ansgar's profile image ansgar posted 10 years ago Permalink
On the command line, with the same libmysql, the LOAD DATA LOCAL command is working fine! I must be missing something. Some option to set, although I think I tested everything already:

ClientFlags := CLIENT_LOCAL_FILES or CLIENT_INTERACTIVE or CLIENT_PROTOCOL_41 or CLIENT_MULTI_STATEMENTS;
Connected := mysql_real_connect(
FHandle,
PAnsiChar(Utf8Encode(FinalHost)),
PAnsiChar(Utf8Encode(FParameters.Username)),
PAnsiChar(Utf8Encode(FParameters.Password)),
nil,
FinalPort,
PAnsiChar(Utf8Encode(FinalSocket)),
ClientFlags
);

This ClientFlags is required, otherwise the server would return some "The command is not allowed on this mysql server".

Ok, then I just added this one:
mysql_options(FHandle, MYSQL_OPT_LOCAL_INFILE, pointer(1));

According to the documentation, that should work, but I still get "Malformed packet".

I'm stuck.
ansgar's profile image ansgar posted 10 years ago Permalink
I just replaced my libmysql from MariaDB 10.0.14/64bit with the one from MySQL 5.6.16/64bit, and it works! Even without calling
mysql_options(FHandle, MYSQL_OPT_LOCAL_INFILE, 0);


So, what's left to be done is testing whether MariaDB plugins still work now.
Code modification/commit 9c0d093 from ansgar.becker, 10 years ago, revision 8.3.0.4854
Fix sql error(2007) Malformed packet, happening on MariaDB-versions of libmysql. Prefer MySQL 5.6.21 versions now. See http://www.heidisql.com/forum.php?t=13454
ansgar's profile image ansgar posted 10 years ago Permalink
r4854 updates libmysql.dll's to MySQL 5.6.21 version. Please check yourself by downloading the latest built *installer*.
ansgar's profile image ansgar posted 10 years ago Permalink
Pluggable authentication does not work any longer, but neither with the older version of libmysql. Hmm..
ansgar's profile image ansgar posted 10 years ago Permalink
jonlegras, I need some feedback from you for if the current installer with the new dll fixes that malformed packet problem for you too. I just don't want to be the only tester here, and I'm intending to make a new HeidiSQL release soon.
[expired user #5700]'s profile image [expired user #5700] posted 10 years ago Permalink
I've had a quick look, and so far seems to be working fine.

I downloaded 8.3.0.4863 full 32/64 installer. Found a csv file I had floating around and gave it a go.

Because I had been using 'client parse', this was the first test. Then repeated with the 'server parse' option.

Everything working as expected. As I use csv imports quite a lot, I'm sure I'll give it plenty more testing soon. Will let you know if there are any problems.

[expired user #5700]'s profile image [expired user #5700] posted 10 years ago Permalink
I have imported quite a few more csv/txt files and everything seems good.
ansgar's profile image ansgar posted 10 years ago Permalink
Nice. So I have just released HeidiSQL v9.0.

Please login to leave a reply, or register at first.