I am using php mysqli_connect for login to a MySQL database (all on localhost)
mysqli_connect
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.
ALTER USER 'root' @ 'localhost' identified with mysql_native_password BY 'root123';