3

Trying to execute a PHP script from the command line and it's giving me this:

c:\tubekit>php harvestYTVideos.php mylist.txt

PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [mysql_old_password] in C:\tubekit\connect.php on line 13

Warning: mysqli_connect(): The server requested authentication method unknown to the client [mysql_old_password] in C:\tubekit\connect.php on line 13 PHP Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in C:\tubekit\connect.php on line 13

Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in C:\tubekit\connect.php on line 13 PHP Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\tubekit\connect.php on line 13

Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\tubekit\connect.php on line 13 Cannot connect to the database:

This is the line it's referring to

$dbh = mysqli_connect("$host","$username","$password") or die("Cannot connect to the database: ". mysqli_error());
kba
  • 19,333
  • 5
  • 62
  • 89
user3386034
  • 55
  • 2
  • 7
  • 3
    your server is using the old mysql password system (bad), but the client only expects the new password format (good). The proper solution is to upgrade your mysql server to something less ancient. – Marc B Mar 12 '14 at 20:16
  • I'm with Hostgator, is there another solution? – user3386034 Mar 12 '14 at 20:44

2 Answers2

1

I had received a similar issue like you which was:

(HY000/2054): The server requested authentication method unknown to the client
Server requested authentication method unknown to the client [caching_sha2_password] mysqli_real_connect():

This was after I upgraded my Mysql to 8.0.22. Mysql 8.0.22 uses caching_sha2_password as its main authentication plugin whilst the previous versions have been using mysql_native_password as their default authentication plugin. To resolve this one of the methods is to revert the MySQL version 8.0 to use MySQL_native_password as its default auth plugin. Tod do this(Ubuntu users):

cd /etc/mysql

Using your favorite text editor open the my.cnf file and after the [mysqld] add the code below.

default_authentication_plugin=mysql_native_password

after that restart service

systemctl restart mysql.service

and that should be able to fix your issue if at all we faced a similar issue.

The second option is to create a new user to DB and authenticate them using the native_password plugin. For full procedure how to do so follow this link

 https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
stanley mbote
  • 956
  • 1
  • 7
  • 17
0

I resolved a similar issue by re-running MySQLInstaller.exe and reconfigured MySQL Server Authentication Method to "Use Legacy Authentication Method (Retain MySql 5.x Compatibility)". Let the other settings remain as you had them in your previous installation. You may confirm the changes by going to MySql Workbench and opening the SQL instance. In the Navigator, open users and privileges and then select the user account. You'll find the Authentication Type there. It should now show Standard and not caching-sha2-password (which is the default setting for MySQL8).

I hope this works for you as it did for me.

nashipae
  • 1
  • 1