I'm running MySQL version 8 on PHP 7.0.
I'm getting the following error when I try to connect to my database from PHP:
Connect Error: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
PHP might show this error
Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in D:\xampp\htdocs\reg\server.php on line 10
How can I fix this problem?
i've try a lot of ways, but only this work for me
thanks for workaround
check your **.env
then type this command
(login as root)
then go to phpmyadmin and login as :
hope it help
Faced the same problem, I was not able to run wordpress docker container with mysql version 8 as its default authentication mechanism is caching_sha2_password instead of mysql_native_password.
In order to fix this problem we must reset default authentication mechanism to mysql_native_password.
Find my.cnf file in your mysql installation, usually on a linux machine it is at the following location - /etc/mysql
Edit my.cnf file and add following line just under heading [mysqld]
default_authentication_plugin= mysql_native_password
Save the file then log into mysql command line using root user
run command FLUSH PRIVILEGES;
as my config.inc.php file, restarted the apache server and it worked. I was still suspicious about it so I stopped the apache and mysql server and started them again and now it's working.
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.
Setting this solved my problem.
In my.cnf file check below 2 steps.
check this value -
old_passwords=0;
it should be 0.
check this also-
[mysqld] default_authentication_plugin= mysql_native_password Another value to check is to make sure
[mysqld] section should be like this.
You have to change MySQL settings. Edit my.cnf file and put this setting in mysqld section:
Then run following command:
Above command will bring into effect the changes of default authentication mechanism.