Saturday 19th August 2017,

Other Stuff

Ξ Leave a comment

Problem With MySQL Old Passwords And PHP 5.3+

posted by steve

Here’s an issue I’ve been having lately with Yii and a Hostgator based MySQL DB on shared hosting.

I develop on my local machine using PHP 5.3 and connect remotely to the Hostgator Database so I can keep the database in one place during development/server staging. PHP 5.3+ requires the use of newer MySQL based passwords for the user you are connecting with but Hostgator still seem to be using old password hashing for MySQL users.

As a result I get the following PDO error message when trying to run Yii …

PDO::__construct() [<a href="pdo.--construct">pdo.--construct</a>]: Premature end of data (mysqlnd_wireprotocol.c:553)

I’ve discovered that if I run the following MySQL queries I can fix the problem for a while (replace [your password] with your actual MySQL user password) …

SET SESSION old_passwords=FALSE;
SET PASSWORD = PASSWORD('[your password]');

Unfortunately this isn’t a permanent fix, but it tends to last a reasonable amount of time. If the error messages start popping up again just run the queries again.
I’ll edit this post if I ever find a more permanent fix.

Obviously this information is only relevant to shared hosting accounts where you cannot change the MySQL my.cnf file yourself. Anyone with full control of MySQL should just permanently set old_passwords to false in my.cnf.

Further info on the fix can be found here…

and here …

Leave a Reply