使用000webhost连接到数据库时,SQLSTATE [HY000] [1045]异常 [英] SQLSTATE[HY000] [1045] exception while connecting to database using 000webhost

查看:152
本文介绍了使用000webhost连接到数据库时,SQLSTATE [HY000] [1045]异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用000webhost连接到我的数据库,但它会给出异常

I am trying to connect to my database using 000webhost but it give exception

连接失败:SQLSTATE [HY000] [1045] ProxySQL错误:访问 拒绝用户'id234191_faisalahmedansari20'@'2a02:4780:bad:f00d :: 4' (使用密码:是)

Connection failed: SQLSTATE[HY000] [1045] ProxySQL Error: Access denied for user 'id234191_faisalahmedansari20'@'2a02:4780:bad:f00d::4' (using password: YES)

下面是我的PHP文件:

Below is my PHP file:

<?php

$host="localhost";
$username="id234191_faisalahmedansari20";
$password="*******";
$dbName="id234191_my_college_admin";

try {
$conn = new PDO("mysql:host=$host;dbname=$dbName", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully"; 
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}

?>

这是特权问题吗?如果是这样,那么我如何在phpMyAdmin中设置特权,因为000webhost使用了它,我不知道如何创建特权.

Is this is any privilege issue? If so then how can i set privilege in phpMyAdmin because 000webhost uses it i don't know how to create privilege.

这是更改密码时的错误屏幕:

Here is error screen while changing password:

以下是尝试创建新数据库且无法更改特权时的一些错误

And below is few error while trying to create new database and can't change privilege

推荐答案

就像您提到的privilege问题

已将该用户分配到该特定数据库吗?

Have assigned that user to that particular DB ?

如果您仍然遇到问题,请在此处检查.

if you still face the problem check here.

打开phpmyadmin->选择数据库-> privileges菜单顶部->您可以在其中看到所有用户列表,还可以编辑其特权.

Open phpmyadmin -> select database -> privileges top of menu -> where you can see all the list of users and edit their privileges also.

这篇关于使用000webhost连接到数据库时,SQLSTATE [HY000] [1045]异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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