0

I am trying to connect to my MySQL version 8.0.11 database in zend server version 7.2.10 using php but I could not connect it

Warning: mysqli::__construct(): Unexpected server respose while doing caching_sha2 auth: 109 in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7

Warning: mysqli::__construct(): MySQL server has gone away in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7

Warning: mysqli::__construct(): (HY000/2006): MySQL server has gone away in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7
Connection failed :MySQL server has gone away

I am getting the following warnings when i try to run my code.

i have searched and tried ALTER USER 'username'@'hostname' IDENTIFIED WITH mysql_native_password BY "userpassword" command but it does not work for me

<?php

$servername = "localhost";
$username = "root";
$password = "hello";

$conn = new mysqli($servername,$username,$password);

if(mysqli_connect_error())
{
    die("Connection failed :" . mysqli_connect_error());
}

echo "CONNECTED SUCCESSFULLY";

?>
Bsquare ℬℬ
  • 4,423
  • 11
  • 24
  • 44
  • Possible duplicate of [PDOException::("PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109") with MySQL 8 / PHP 7.2 / Laravel](https://stackoverflow.com/questions/51844962/pdoexceptionpdo-construct-unexpected-server-respose-while-doing-cachin) – digijay Dec 23 '18 at 11:33
  • not working that's why i am asking it again – Pintu Bordoloi Dec 23 '18 at 13:06

1 Answers1

0

Try with caching_sha2_password:

ALTER USER 'username'@'hostname'IDENTIFIED WITH caching_sha2_password BY 'userpassword';
EvE
  • 734
  • 3
  • 13