警告:mysqli :: mysqli():(HY000/1045):拒绝用户'database'@'localhost'(使用密码:NO)的访问 [英] Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'database'@'localhost' (using password: NO) in

查看:272
本文介绍了警告:mysqli :: mysqli():(HY000/1045):拒绝用户'database'@'localhost'(使用密码:NO)的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用php连接数据库,出现此错误:

I'm trying to connect my database with php, I've got this error:

警告:mysqli :: mysqli():(HY000/1045):在C:\ wamp64 \ www \ Login test 2.0 \ connectivity.php中,拒绝用户'typen'@'localhost'(使用密码:NO)的访问在第7行

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'typen'@'localhost' (using password: NO) in C:\wamp64\www\Login test 2.0\connectivity.php on line 7

我的php代码是:

<?php
$servername = "localhost";
$username = "typen";
$password = "";

$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
 die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";

错误通知:

我的数据库名称是:"typen" 它在whampserver(localhost)上运行 据我所知,我没有为数据库设置密码,甚至没有为phpmyadmin设置密码.

My data base name is: "typen" it's run on a whampserver (localhost) And as far as I know I don't have a password set for my database, I don't even have a password for phpmyadmin.

请帮助我.

推荐答案

您说您的数据库名称是typen,通常默认的数据库用户名是root,没有密码. 尝试以下代码:

You said your database name is typen, and generally default database username is root with no password. Try below code:

$servername = "localhost";
$username = "root";
$password = "";
$db = "typen";

$conn = new mysqli($servername, $username, $password,$db);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";

这篇关于警告:mysqli :: mysqli():(HY000/1045):拒绝用户'database'@'localhost'(使用密码:NO)的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆