警告:mysqli_connect(): (28000/1045): 拒绝访问
Posted
技术标签:
【中文标题】警告:mysqli_connect(): (28000/1045): 拒绝访问【英文标题】:Warning: mysqli_connect(): (28000/1045): Access denied for 【发布时间】:2016-09-27 09:09:21 【问题描述】:我的网页上出现了两个错误。而且我不太习惯搞数据库,mysql,所以我需要你帮助我!
警告:mysqli_connect(): (28000/1045): Access denied for user 'u467224226_yjygu'@'10.1.2.19' (using password: YES) in /home/u467224226/public_html/galeria/api.php on line 8
警告:mysqli_error() 期望参数 1 为 mysqli,布尔值在 /home/u467224226/public_html/galeria/api.php 第 8 行给出
这是代码。
<?php // connect to the database $user_name = ""; $password = ""; $database = ""; $host_name = "localhost";
$con = mysqli_connect($host_name ,$user_name ,$password,$database) or die("Error " . mysqli_error($con)); //check connection
echo "Connection opened";
mysql_close($con); ?>
<?php require_once('include/config.inc.php'); header("Content-type: application/x-javascript");
$connect = mysql_connect($CONFIG['dbserver'],$CONFIG['dbuser'],$CONFIG['dbpass']) or die('Erro ao conectar ao servidor'); $connect_db = mysql_select_db($CONFIG['dbname'], $connect) or die ('Erro ao conectar ao banco de dados');
$resultado = mysql_query("SELECT * FROM `cpg_albums` ORDER BY `cpg_albums`.`aid` DESC LIMIT 0 , 4", $connect)
or die('Nenhum album encontrado com esta query');
echo 'document.write(\'';
if(mysql_num_rows($resultado) == 0)
echo 'Nenhum álbum cadastrado';
else echo '<section id="ultimas_fotos"> ';
while($row = mysql_fetch_array($resultado))
echo ' ';
$album_id = $row['aid'];
$subresult = mysql_query("SELECT * FROM `cpg_pictures` where aid=$album_id order by pid DESC LIMIT 0, 20");
if(mysql_num_rows($subresult) == 0)
$album_img = "http://tisdalephotos.com/images/thumbs/thumb_nopic.png";
else
while($subrow = mysql_fetch_array($subresult))
$album_img = "http://tisdalephotos.com/albums/".$subrow['filepath'].'thumb_'.$subrow['filename'] .$subrow['datebrowse'];
echo '<div id="ultalb"><a href="http://tisdalephotos.com/thumbnails.php?album='.$album_id.' "><img src="'.$album_img.'" /></a><div id="ultalbt"><a href="http://tisdalephotos.com/thumbnails.php?album='.$album_id.' ">+</a></div></div>';
echo '';
echo '</tr></section>';
echo '\');';
?>
【问题讨论】:
你有什么想法吗? SO 不仅仅是一个调试服务。 登录信息(密码)错误? 如果您发现此处提供的答案有帮助,请点赞和/或标记为已接受,以便其他有类似问题的用户受益。 【参考方案1】:假设您的密码正确。
您的用户是否拥有正确的权限?以root身份登录然后运行:
select Host, User from mysql.user;
查看为您的用户列出的内容。
如果它丢失了,你可以运行:
CREATE USER 'u467224226_yjygu'@'%%' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON * . * TO 'u467224226_yjygu'@'%%';
FLUSH PRIVILEGES;
【讨论】:
以上是关于警告:mysqli_connect(): (28000/1045): 拒绝访问的主要内容,如果未能解决你的问题,请参考以下文章
警告:mysqli_connect():MySQL 服务器已消失
警告:mysqli_connect():(HY000/1045):用户'record'@'localhost'的访问被拒绝(使用密码:YES)[重复]
警告:mysqli_connect(): (HY000/2002): 没有这样的文件或目录
警告:mysqli_connect(): (HY000/1049): 仅在 mac 终端中的未知数据库