每当我试着与我的凭据连接到我的数据库,它并没有与用户进行连接,例如,当我尝试使用MySQL数据库没有与名称连接
mysqli_connect("localhost","dbuser","","database")
连接到我的本地数据库它返回
Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'database'
每当我试着与我的凭据连接到我的数据库,它并没有与用户进行连接,例如,当我尝试使用MySQL数据库没有与名称连接
mysqli_connect("localhost","dbuser","","database")
连接到我的本地数据库它返回
Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'database'
使用所有四个参数上mysqli_connect()
您无法连接从上面的代码,我可以告诉你的
host : "localhost"
user: "dbuser"
password: ""
database name: "database"
做到这一点,
$conn = mysqli_connect("localhost", "dbuser", "");
mysqli_select_db($conn, "database");
// to check if you're connected, after tested and see you can take off the code below...
if ($conn) {
echo "Connected";
} else {
echo "Connection failed";
}
如果你认真想使用上述所有四个参数连接?
$conn = new mysqli("localhost","dbuser","","database");
// to check if you're connected, after tested and see you can take off the code below...
if ($conn) {
echo "Connected";
} else {
echo "Failed";
}
希望这有帮助吗?
只要把引号像这样“”代替“”之间的空间,以显示在您的查询密码值作为空的,因为在编程值为0(假)或1(真)必须有你不能有分毫,并希望事情
这是当你没有在本地的phpmyadmin像root用户为用户设置密码,并检查拼写错误
[警告
可能重复:mysqli的\ _connect()( HY000/1045):访问被拒绝的用户 '用户名' @ '本地主机'(使用密码:YES)](https://stackoverflow.com/questions/25174183/warning-mysqli-connect-hy000-1045-access-denied-换用户usernameloca) – knizer