PHP 7.2.8 & MySQL 8.0

A good news for all PHP CMS users like Drupal and Joomla!, PHP 7.2.8 (available on Remi’s repo for those using rpms) supports the new MySQL 8.0 default authentication plugincaching_sha2_password‘ !

So, I’ve installed PHP 7.2.8:

And I’ve my user (here joomla) uses the caching_sha2_password:

I give acces those this user to SELECT in mysql.user table:

Now let’s share my wonderful PHP skills :

<!--?php 
$mysqli = new mysqli('localhost', 'joomla', 'joomla', 'joomla_db'); if ($mysqli->connect_errno) {
   echo "Sorry, this website is experiencing problems.<p>";
   echo "Error: Failed to make a MySQL connection, here is why: <br>";
   echo "Errno: " . $mysqli->connect_errno . "<br>";
   echo "Error: " . $mysqli->connect_error . "<br>";
   exit;
}

echo "Wooohoooo it works with PHP" . phpversion() ."!!<br><hr>";

$sql = "select user, plugin from mysql.user where user = 'joomla'";
if (!$result = $mysqli->query($sql)) {
   echo "Error: Our query failed to execute and here is why: &lt;br&gt;";
   echo "Query: " . $sql . "<br>";
   echo "Errno: " . $mysqli->errno . "<br>";
   echo "Error: " . $mysqli->error . "<br>";
   exit;
}

$user = $result->fetch_assoc();
echo "user: " . $user['user'] . "<br>";
echo "plugin: " . $user['plugin'];

$result->free();
$mysqli->close();
?>

And here is the result:

In conclusion, it seems the PHP team is taking care of MySQL 8.0 support and when you check the release tags in the github commit, you can see that this is not only for PHP 7.2.8 ! Good job ! So, please upgrade to a PHP version supporting MySQL 8 !

Subscribe to Blog via Email

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

One comment

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.