PHP,MySQL返回“连接失败:服务器请求的客户端身份验证方法未知”

时间:2019-02-24 21:32:53

标签: php mysqli

尝试连接到本地Mysqli DB。

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

返回此: 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

任何反馈都会有所帮助。正在研究此问题,但没有确定的解决方案。

1 个答案:

答案 0 :(得分:0)

您可以按照以下代码尝试使用此 mysqli_connect()功能吗? 还请确保数据库用户名和密码正确,并且用户具有连接数据库的权限

<?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);
      ?>