megacolorboy

Back

Published on March 12th, 2021

MySQL

Use MySQL 8.0 with Native Password Authentication

Last month, I was configuring an Ubuntu Server to deploy a client's project that uses MySQL 8.0 and PHP 7.2. So, I installed the necessary dependencies and finally installed MySQL 8.0, created a new schema and imported the database tables required for the project.Next, I typed the project URL and ran into this error:Unable to load plugin 'cachingsha2password'If you're running PHP 7.2 and facing this error, you should know that PHP 7.2 doesn't support native password authentication by default. But it's a simple fix, all you have to do is either one of the following:Alter the current user's authentication to native passwordCreate a new user with native password authentication Alter the current user's authentication to native password Create a new user with native password authenticationFor the changes to take effect, you need to reload the privileges by typing the following:Hope this helps you out!

1 minute read

Last month, I was configuring an Ubuntu Server to deploy a client's project that uses MySQL 8.0 and PHP 7.2. So, I installed the necessary dependencies and finally installed MySQL 8.0, created a new schema and imported the database tables required for the project.

Next, I typed the project URL and ran into this error:

Unable to load plugin 'cachingsha2password'

If you're running PHP 7.2 and facing this error, you should know that PHP 7.2 doesn't support native password authentication by default. But it's a simple fix, all you have to do is either one of the following:

  1. Alter the current user's authentication to native password
  2. Create a new user with native password authentication

Alter the current user's authentication to native password


ALTER USER 'your_user'@'your_server_host' IDENTIFIED WITH mysql_native_password BY 'your_password';

Create a new user with native password authentication


CREATE USER 'your_user'@'your_server_host ' IDENTIFIED WITH mysql_native_password BY 'your_password'

For the changes to take effect, you need to reload the privileges by typing the following:


FLUSH PRIVILEGES;

Hope this helps you out!