close

[Solved] PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Error Occurs?

Today I get the following error PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client in php.

How To Solve PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Error ?

  1. How To Solve PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Error ?

    To Solve PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Error I'm using Laravel Lumen to build a small application.
    For me it was because I didn't had the DB_USERNAME defined in my .env file.

  2. PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client

    To Solve PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Error I'm using Laravel Lumen to build a small application.
    For me it was because I didn't had the DB_USERNAME defined in my .env file.

Solution 1

You have to change MySQL settings. Edit my.cnf file and put this setting in mysqld section:

[mysqld]
default_authentication_plugin= mysql_native_password

Then run following command:

FLUSH PRIVILEGES;

Above command will bring into effect the changes of default authentication mechanism.

Solution 2

I’m using Laravel Lumen to build a small application.
For me it was because I didn’t had the DB_USERNAME defined in my .env file.

DB_USERNAME=root

Setting this solved my problem.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment