【问题标题】:PHP, MySQL returns "Connection failed: The server requested authentication method unknown to the client" [duplicate]PHP,MySQL返回“连接失败:服务器请求客户端未知的身份验证方法” [重复]
【发布时间】:2019-07-18 07:12:20
【问题描述】:

正在尝试连接到本地 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

任何反馈都会有所帮助。一直在研究这个问题,但没有明确的解决方案。

【问题讨论】:

标签: php mysqli


【解决方案1】:

你能按照下面的代码试试这个 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);
      ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-21
    • 2019-02-21
    • 2020-12-03
    • 2018-11-06
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多