0

Trying to connect to local Mysqli DB.

Database Connection: <?php $con= new mysqli("localhost","Kobe24","Kobei987","Bkn_Data"); if ($con->connect_error) { die("Connection failed: " . $con->connect_error); }

Returns this: Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in C:\Apache24\htdocs\poc\practice_project\database_connection.php on line 1 Connection failed: The server requested authentication method unknown to the client

Any feedback would help. Been researching this problem but no definitive solutions.

BNichols
  • 15
  • 1
  • 8
  • try this post https://stackoverflow.com/questions/1340488/mysql-php-incompatibility – MHewison Feb 24 '19 at 21:37
  • it will be useful if you can provide more info about the user you use. can you please login to mysql as root (from console or phpmyadmin for example) and post output of `select * from mysql.user where User = YOURUSERNAME` – Alex Zheka Feb 24 '19 at 21:37
  • Try change MySQL Auth method like here https://stackoverflow.com/questions/44946270/er-not-supported-auth-mode-mysql-server/50547109#50547109 – Archil Labadze Feb 24 '19 at 22:24

1 Answers1

-2

Can you try this mysqli_connect() functions as per code below. Please also ensure that database user and password are correct and that the user has permission to connect to the database

<?php
         $dbhost = 'localhost:3306';
         $dbuser = 'enter database user';
         $dbpass = 'enter password';
         $con = mysqli_connect($dbhost, $dbuser, $dbpass);

         if(! $con ){
            die('Could not connect: ' . mysqli_error());
         }
         echo 'Connected successfully';
         mysqli_close($con);
      ?>
Nancy Moore
  • 2,322
  • 2
  • 21
  • 38