Click here to Skip to main content
14,934,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am trying crud operation with php and MY Sql


I am using IIS to run php file php file is working good but i am unable to do crud operation with MYSQL

I am using MYSQL Workbench 8.0

What I have tried:

<?php
$servername = "localhost";
$username = "root";
$password = "Pass@123";

// Create connection
$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>


Error message

Connection failed: The server requested authentication method unknown to the client
Posted
Updated 1-Aug-18 2:49am

The PHP mysqli connector does not support yet the new default MySQL 8.0 authentication method.

See Upgrading to MySQL 8.0 : Default Authentication Plugin Considerations | MySQL Server Blog[^].
   
Comments
Gurpreet Arora Malhotra 1-Aug-18 8:56am
   
I tried that
ALTER USER 'root'@'localhost'
IDENTIFIED WITH mysql_native_password
BY 'password'; in MySQL and Now getting
Connection failed: Access denied for user 'root'@'localhost' (using password: YES)


I changed the Password and Its working Good Now Thanks
Jochen Arndt 1-Aug-18 9:11am
   
The link from my solution suggests to change the corresponding option in the mysqld configuration file until the client (PHP mysqli here) supports the new authentication method.

But changing the method for the user should work too. Do you have passed the correct password?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900