I am using php mysqli_connect
for login to a MySQL database (all on localhost)
If you're on Windows and it's not possible to use caching_sha2_password
at all, you can do the following:
The Installer will make all the configuration changes needed for you.
ALTER USER 'mysqlUsername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlUsernamePassword';
Remove quotes (') after ALTER USER
and keep quote (') after mysql_native_password BY
It is working for me also.
I solve this by SQL command:
ALTER USER 'mysqlUsername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlUsernamePassword';
which is referenced by https://dev.mysql.com/doc/refman/8.0/en/alter-user.html
if you are creating new user
CREATE USER 'jeffrey'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
which is referenced by https://dev.mysql.com/doc/refman/8.0/en/create-user.html
this works for me
Like many many people, I have had the same problem. Although the user is set to use mysql_native_password, and I can connect from the command line, the only way I could get mysqli() to connect is to add
default-authentication-plugin=mysql_native_password
to the [mysqld] section of, in my setup on ubuntu 19.10, /etc/mysql/mysql.conf.d/mysqld.cnf
I tried this in Ubuntu 18.04 and is the only solution that worked for me:
ALTER USER my_user@'%' IDENTIFIED WITH mysql_native_password BY 'password';
I ran the following command
ALTER USER 'root' @ 'localhost' identified with mysql_native_password BY 'root123';
in the command line and finally restart MySQL in local services.