PHP and MySQL 9

As you can read in my previous post related to MySQL 9 and authentication, the old mysql_native_password plugin has been removed.

In that post, I showed an example using PHP 7.2, the default version in OL8.

If you are using PHP and you want to use MySQL 9, you must be using a more recent version that fully supports the default authentication plugin caching_cha2_password.

Here is a summary table illustrating which PHP versions are compatible with MySQL 9:

This is the test using OL8 and PHP from the official repository and from Remi’s repo:

[root@mysql1 ~]# php test.php 
PHP version: 7.2.24
PHP Warning:  mysqli::__construct(): The server requested authentication method
 unknown to the client [caching_sha2_password] in /root/test.php on line 9
PHP Warning:  mysqli::__construct(): (HY000/2054): The server requested
 authentication method unknown to the client in /root/test.php on line 9
Connection failed: The server requested authentication method unknown to the client

[root@mysql1 ~]# php test.php 
PHP version: 7.2.34
PHP Warning:  mysqli::__construct(): The server requested authentication method
 unknown to the client [caching_sha2_password] in /root/test.php on line 9
PHP Warning:  mysqli::__construct(): (HY000/2054): The server requested
 authentication method unknown to the client in /root/test.php on line 9
Connection failed: The server requested authentication method unknown to the client


[root@mysql1 ~]# php test.php 
PHP version: 7.3.33
PHP Warning:  mysqli::__construct(): The server requested authentication method
 unknown to the client [caching_sha2_password] in /root/test.php on line 9
PHP Warning:  mysqli::__construct(): (HY000/2054): The server requested
 authentication method unknown to the client in /root/test.php on line 9
Connection failed: The server requested authentication method unknown to the client


[root@mysql1 ~]# php test.php 
PHP version: 7.4.33
Connected successfully
MySQL version: 9.0.0


[root@mysql1 ~]# php test.php 
PHP version: 8.0.30
Connected successfully
MySQL version: 9.0.0


[root@mysql1 ~]# php test.php 
PHP version: 8.1.29
Connected successfully
MySQL version: 9.0.0

[root@mysql1 ~]# php test.php 
PHP version: 8.2.21
Connected successfully
MySQL version: 9.0.0


[root@mysql1 ~]# php test.php 
PHP version: 8.3.9
Connected successfully
MySQL version: 9.0.0

Be ready to upgrade your legacy code to a newer version of PHP, it will be good for MySQL and PHP 😉

Enjoy coding in PHP and storing your data in MySQL!

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Leave a Reply

Your email address will not be published. Required fields are marked *

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.