Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: ERROR 2027 (HY000): Malformed packet

Tags:

mysql

tcp

I am not able to connect a MySQL server remotely. The connection seems to be ok because with telnet [ip] [port] I get response:

 4.1.3b-beta-nt-max▒ <0v '[uZ,? B {efSLa $, Q4N 

When executed by command line or by MySQL Workbench 6.3

 mysql -u [user] -p -h [host] 

I get the same error:
ERROR 2027 (HY000): Malformed packet

like image 429
Edvaldo Silva Avatar asked Aug 12 '17 19:08

Edvaldo Silva


5 Answers

It is a mysql client bug, I've searched about it and it is a old auth switch request. Your client it is out of date, using a old protocol communication, now, if it is a Workbench problem too your just the Client, you need to update or downgrade the MySQL Client first and try to run it alone.

Here, it is the same question with a more complete answer: https://dba.stackexchange.com/questions/135343/server-responds-with-empty-packet-during-session-negotiation-resulting-in-client

And, for the new Auth protocol, on connection phase: https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase.html

like image 73
Roberto Gonçalves Avatar answered Nov 04 '22 19:11

Roberto Gonçalves


You must upgrade the "old_password" hashed password:

SET PASSWORD FOR 'existinguser'@'localhost' = PASSWORD('existingpass');

So you can login in an "old" MySQL server, using a recent Workbench version

like image 35
Marcelo Amorim Avatar answered Nov 04 '22 18:11

Marcelo Amorim


If you need to connect to pre-4.1 MySQL servers from later MySQL versions (5.7+), you will need to use "--skip-secure-auth" option from the client. And the client version cannot be newer than v5.7.4 because this option had been removed in 5.7.5. You can download version 5.7.4_m14 from mysql's archive website. For example,

$ mysql -uuser -p -hserver --skip-secure-auth
like image 25
Tomofumi Avatar answered Nov 04 '22 19:11

Tomofumi


I had the same error trying to connect to a MariaDB server with the MySQL client mysql-client. I solved it by installing mariadb-client (that overwrites the mysql binary, so use the same command to connect).

like image 1
ryancey Avatar answered Nov 04 '22 19:11

ryancey


I did face this issue for normal select query. It was weird that when I was using small-case 's' in the query statement, it was giving me the same error. The I figured out that this happens as internally it is trying to retrieve the data from mysql cache. It was not because of the case of 's' in the select query.

//Returned Error
select * from foo;

//This worked fine
Select * from foo;

//This also worked fine
select SQL_NO_CACHE * from foo;

From this I was able to conclude that it was the issue as it was using Cached data.

like image 1
Ravi Bhanushali Avatar answered Nov 04 '22 19:11

Ravi Bhanushali