3

When i have upgraded my PHP and MySQL versión, this errors are generating

Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]
Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in

I am using this versions :

Codeigniter : 3.1.9 
PHP         : 7.2.6
MySql       : 8.0.11

Thanx...

Shubham Azad
  • 786
  • 2
  • 10
  • 25

3 Answers3

3

A Possible solution is to change the authentication plugin of the default user of the mysql or the root user of mysql .

just log in to mysql console(terminal/phpmyadmin) as root user , and reset the password as

ALTER USER 'mysqlUsername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlUsernamePassword';

i would change the passwords of all existing users this way just to be safe,

you can get the list of existing users and their fields via ,

use mysql ;

select * from user \G;

i setup the mysql this way since the start and have had no such errors .

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

phpMyAdmin on MySQL 8.0

Taher Khalil
  • 116
  • 1
  • 11
1

It's the version of MySql, after version 8.0 it doesn't support the caching_sha2_password plugin

However if changing it's version is not an option you can try adding this in your mysql configuration file and then restart the server

[mysqld]
default-authentication-plugin=mysql_native_password
lessan
  • 370
  • 4
  • 15
  • when i had this problem, it worked for me, be careful at what config file is loaded, there are more of them and maybe you changed the wrong one also you should restart your mysql server, not the apache – lessan Jul 23 '18 at 07:30
  • i have made change in my.cng file – Shubham Azad Jul 23 '18 at 08:32
-1

One extra suggestion:

if the problem persists, try to run your IDE as Administrator.

I did all the steps I saw in several answers in StackOverflow, but it was only after I run PhpStorm as Admin that I could make a successful login.

Luis Cunha
  • 51
  • 4
  • Why should running the IDE with different permissions have an impact on the code getting executed? – Nico Haase Oct 04 '18 at 09:56
  • Hi Luis. Welcome to Stackoverflow. Inputs that do not answer the questions directly, like the suggestion you made, should be posted as comments. (I understand you may not have enough reputation to comment on questions right away - but that's the way it is here, sorry.) – Sterex Oct 04 '18 at 10:18