php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

Posts regarding the MySQL database server
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

Post by mister_v »

Hi,

I get the following error whe I tried to connect with php to MySQL server.
mysqli::__construct(): The server requested authentication method unknown to the client

How can I fix this?
I use standard login function:
$dbconn=new mysqli('127.0.0.1','user','passwd','database');
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

Post by chris »

MYSQL has changed it type of password (since Mysql 8 ?)
Anyway the easiest solution, is execute the following SQL command on MYSQL

Code: Select all

ALTER USER 'mysqlUsername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlUsernamePassword';
It should solve your problem.
Post Reply