我已经写在下面了 php
连接mysql数据库的代码:
<?php
// Connect to MySQL
$servername = "localhost";
$username = "user";
$password = "A11b22c33&";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
但是,此代码无法建立任何连接。我只得到以下错误:
currently unable to handle this request.
HTTP ERROR 500
但是,如果我删除了代码的连接部分 php
文件工作正常,即我收到的回音为“连接成功”
<?php
// Connect to MySQL
$servername = "localhost";
$username = "user";
$password = "A11b22c33&";
echo "Connected successfully";
?>
有人能帮我理解出了什么问题吗?我已经检查了用户名和密码,他们是完美的
1条答案
按热度按时间lmvvr0a81#
我刚安装了
mysqlnd
使用apt-get install php-mysqlnd
,效果很好。