Guide to fix MySQL Auth Error using PHP 5, mysqli & MySQL 5

  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1585

Post 3+ Months Ago

If you're using a newly installed copy of PHP 5.3.0, mysqli enabled and when trying to connect to the database using mysqli (when using this test script):
PHP Code: [ Select ]
$mysqli = new mysqli('<ip>', '<user>', '<pass>', '<db>');
if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
  1. <?php
  2. $mysqli = new mysqli('<ip>', '<user>', '<pass>', '<db>');
  4. if ($mysqli->connect_error) {
  5.     die('Connect Error (' . $mysqli->connect_errno . ') '
  6.             . $mysqli->connect_error);
  7. }
  8. ?>

And if you get an error set like this one:
PHP wrote:
Warning: mysqli::mysqli() [mysqli.mysqli]: OK packet 6 bytes shorter than expected in <path> on line <#>
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2000): mysqlnd cannot connect to MySQL 4.1+ using old authentication in <path> on line <#>
Connect Error (2000) mysqlnd cannot connect to MySQL 4.1+ using old authentication

Your MySQL server may be configured to use old password authentication.

Checklist to troubleshoot:
  • Consult: for work arounds.
  • Do you best to make sure my client isn't using old authentication: Run a test phpinfo() script on your PHP configuration and the phpinfo() function says your client API of mysqlnd is version 5+.
  • Check to make sure the MySQL server version is 5+

Most likely if all of the things above have applied to your case, check your MySQL 5 server and see if it is configured using the --old-passwords option. If you have limited access to your server, check the passwords column to see if it is in "short" format instead of "long" format. Also check to see if the passwords have a "*" in front of them, newer MySQL "long" format passwords have this.

Hope this helps someone.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: Bogey and 114 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.