When I try and connect to my database on XAMPP it gives me this error:
(当我尝试连接到XAMPP上的数据库时,出现此错误:)
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'user'@'localhost' (using password: YES)
(警告:mysqli :: __ construct():(HY000 / 1045):用户'user'@'localhost'的访问被拒绝(使用密码:是))
I have created another user and am logged in to xampp with that.
(我创建了另一个用户,并使用该用户登录到xampp。)
I use the Atom editor and am on macOS Mojave. (我使用Atom编辑器,并且在macOS Mojave上运行。)
This is my code - (这是我的代码-)
<?php
$dbhost = "localhost";
$dbuser = "username";
$dbpass = "password";
$db = "dbname";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s
".mysqli_connect_error());
echo "Connected Successfully";
return $conn;
mysqli_connect_error();
?>
I have written username and password for confidentiality.
(为了保密起见,我已经写了用户名和密码。)
It is replaced by my real username and password in my code. (它由我的代码中的真实用户名和密码替换。)
The same applies to the 'user'@localhost in the error message (错误消息中的'user'@ localhost同样适用)
ask by LeoMessi 10 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…